A long-lived project that still receives updates
A set of tools for building reliable services of any complexity
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 3.8
>= 2.23
>= 2.2.0
>= 13.2
>= 3.13
>= 1.9
>= 2.5

Runtime

>= 0.3
>= 0.2
>= 2.6
>= 1.14
 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 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 for easy testing
  • ๐Ÿ“Š Structured Output - Consistent Result object pattern
  • ๐Ÿ”ง Highly Configurable - Extensions, helpers, and custom options
  • ๐Ÿ“š Well Documented - Comprehensive guides and examples

๐Ÿš€ Quick Start

Installation

gem "servactory"

Define service

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

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 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!

๐Ÿ“„ License

Servactory is available as open source under the terms of the MIT License.