orchestrator-crystal
orchestrator
Allow you to split your logic into composable multiple pieces.
Installation
Add this to your application's shard.yml
:
dependencies:
orchestrator:
github: alex-lairan/orchestrator
Usage
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
Development
Do what ever you want.
Contributing
- 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
Contributors
- alex-lairan Alexandre Lairan - creator, maintainer
Repository
orchestrator-crystal
Owner
Statistic
- 1
- 1
- 0
- 1
- 1
- almost 6 years ago
- October 24, 2018
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 07:07:29 GMT
Languages