Allow you to split your logic into composable multiple pieces.
Add this to your application's shard.yml
:
dependencies:
orchestrator:
github: alex-lairan/orchestrator
require "orchestrator"
You have to create layers
class Registrator < Orchestrator::Layer
def call(input : Hash)
# logic here
# in case of success
return Monads::Success.new(input)
# in case of failure
return Monads::Failure.new(input)
end
end
class Validator < Orchestrator::Layer
def call(input : Hash)
# logic here
# in case of success
return Monads::Success.new(input)
# in case of failure
return Monads::Failure.new(input)
end
end
Then create a composer
class UserRegistration < Orchestrator::Composer
compose :validation, klass: Validator
compose :registration, klass: Registrator
end
That it, now call this super class !
composer = UserRegistration.new
result = composer.call(data)
if result.success?
# If success
else
# If failure
end
Do what ever you want.
- Fork it (https://github.com/alex-lairan/orchestrator/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- alex-lairan Alexandre Lairan - creator, maintainer