https://github.com/servactory/servactory
Powerful Service Object for Ruby applications
https://github.com/servactory/servactory
rails ruby ruby-on-rails servactory service-factory service-object service-objects services
Last synced: about 1 month ago
JSON representation
Powerful Service Object for Ruby applications
- Host: GitHub
- URL: https://github.com/servactory/servactory
- Owner: servactory
- License: mit
- Created: 2023-04-28T21:40:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-02T08:19:50.000Z (12 months ago)
- Last Synced: 2025-04-03T05:32:29.164Z (12 months ago)
- Topics: rails, ruby, ruby-on-rails, servactory, service-factory, service-object, service-objects, services
- Language: Ruby
- Homepage: https://servactory.com
- Size: 1.89 MB
- Stars: 21
- Watchers: 5
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ruby - Servactory - A set of tools for building reliable service objects of any complexity. (Business logic)
- fucking-awesome-ruby - Servactory - A set of tools for building reliable service objects of any complexity. (Business logic)
README
A set of tools for building reliable services of any complexity.
## ๐ Documentation
See [servactory.com](https://servactory.com) for comprehensive documentation, including:
- Detailed guides for all features
- Advanced configuration options
- Best practices and patterns
- Migration guides
- API reference
## ๐ก Why Servactory?
Building reliable services shouldn't be complicated. Servactory provides a battle-tested framework for creating service objects with:
- ๐ก๏ธ **Type Safety** - Enforce types on inputs and outputs, catch errors early
- โ
**Built-in Validation** - Rich validation DSL with custom rules
- ๐งช **Test-Friendly** - RSpec matchers and service mocking helpers
- ๐ **Structured Output** - Consistent Result object pattern
- ๐ง **Highly Configurable** - Extensions, helpers, and custom options
- ๐ **Well Documented** - Comprehensive guides and examples
## ๐ Quick Start
### Installation
```ruby
gem "servactory"
```
### Define service
```ruby
class UserService::Authenticate < Servactory::Base
input :email, type: String
input :password, type: String
output :user, type: User
make :authenticate!
private
def authenticate!
if (user = User.authenticate_by(email: inputs.email, password: inputs.password)).present?
outputs.user = user
else
fail!(message: "Authentication failed", meta: { email: inputs.email })
end
end
end
```
### Usage in controller
```ruby
class SessionsController < ApplicationController
def create
service = UserService::Authenticate.call(**session_params)
if service.success?
session[:current_user_id] = service.user.id
redirect_to service.user
else
flash.now[:alert] = service.error.message
render :new, status: :unprocessable_entity
end
end
private
def session_params
params.require(:session).permit(:email, :password)
end
end
```
## ๐ค Contributing
We love contributions! Check out our [Contributing Guide](https://servactory.com/CONTRIBUTING) to get started.
**Ways to contribute:**
- ๐ Report bugs and issues
- ๐ก Suggest new features
- ๐ Improve documentation
- ๐งช Add test cases
- ๐ง Submit pull requests
## ๐ Acknowledgments
Special thanks to all our [contributors](https://github.com/servactory/servactory/graphs/contributors)!
## ๐ License
Servactory is available as open source under the terms of the [MIT License](./LICENSE).