An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          






Servactory



A set of tools for building reliable services of any complexity.


Gem version
Release Date
Downloads
Ruby version

## ๐Ÿ“š 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).