Quickstep is a lightweight business operation tool inspired by dry-operation. It provides a structured way to execute multi-step operations with built-in success and failure handling.
Add this line to your application's Gemfile:
gem 'quickstep', '1.0.0'Or install it manually:
gem install quickstepOperations in Quickstep are composed of sequential steps. Each step returns either a Success or a Failure. If any step fails, the operation halts immediately.
require 'quickstep'
class MyOperation
include Quickstep
def call(input)
step validate(input)
step process(input)
end
private
def validate(input)
input[:valid] ? Success(input) : Failure(:invalid_input)
end
def process(input)
Success(result: input[:value] * 2)
end
end
result = MyOperation.new.call(valid: true, value: 5)
if result.success?
puts "Success: #{result.value}"
else
puts "Failure: #{result.value}"
endIn Quickstep, you can use the result of another operation as a step in your operation.
This allows you to compose operations naturally and reuse existing logic.
class MainOperation
include Quickstep
def call
step step1
step SecondOperation.new.call # chaining another operation
end
private
def first_step
Success("first step")
end
end
class SecondOperation
include Quickstep
def call
step first_step
step second_step
end
private
def first_step
Success("Step from SecondOperation")
end
end- Any value returned by
callthat is not already aSuccessorFailurewill be wrapped in aSuccessautomatically. - Operations can be executed either via an instance or directly on the class:
# Using an instance
result = MyOperation.new.call(:input)
# Using the class method shortcut
result = MyOperation.call(:input)Quickstep is available under the MIT License.