The project is in a healthy, maintained state
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
 Dependencies

Development

>= 1.31
>= 2.1.0
>= 3.1.3
~> 13.0
~> 3.12
~> 1.5
~> 2.5

Runtime

~> 0.2
~> 0.2
>= 5.1, < 8.1
~> 2.6
~> 1.14
 Project Readme

Servactory

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

Gem version Release Date

Documentation

See servactory.com for documentation.

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

This project is intended to be a safe, welcoming space for collaboration. Contributors are expected to adhere to the Contributor Covenant code of conduct. We recommend reading the contributing guide as well.

License

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