A set of tools for building reliable services of any complexity.
See servactory.com for comprehensive documentation, including:
- Detailed guides for all features
- Advanced configuration options
- Best practices and patterns
- Migration guides
- API reference
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
gem "servactory"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
endclass 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
endWe love contributions! Check out our Contributing Guide to get started.
Ways to contribute:
- 🐛 Report bugs and issues
- 💡 Suggest new features
- 📝 Improve documentation
- 🧪 Add test cases
- 🔧 Submit pull requests
Special thanks to all our contributors!
Servactory is available as open source under the terms of the MIT License.