README.md in nxt_pipeline-0.4.0 vs README.md in nxt_pipeline-0.4.1

- old
+ new

@@ -190,58 +190,15 @@ end ``` Note that the `after_execute` callback will not be called, when an error is raised in one of the steps. See the previous section (_Error callbacks_) for how to define callbacks that run in case of errors. -### DSL +### Step resolvers -The gem also comes with an easy DSL to make pipeline handling in your code more convenient. -Simply include NxtPipeline::Dsl in your class: +NxtPipeline is using so called step_resolvers to find the constructor for a given step by the arguments passed in. +You can also use this if you are not fine with resolving the constructor from the step argument. Check out the +`nxt_pipeline/spec/step_resolver_spec.rb` for examples how you can implement your own step_resolvers. -```ruby -class MyAwesomeClass - include NxtPipeline::Dsl - - # register a pipeline with a name and a block - pipeline :validation do |p| - pipeline.constructor(:validate) do |step, arg:| - result = step.validator.call(arg: arg) - result && { arg: result } - end - - pipeline.step :validate, validator: NameValidator - pipeline.step :validate, validator: AdressValidator - pipeline.step :validate, validator: BankAccountValidator - pipeline.step :validate, validator: PhoneNumberValidator - - p.on_error ValidationError do |step, opts, error| - # ... - end - end - - pipeline :execution do |p| - p.step do |_, arg:| - { arg: arg.upcase } - end - - p.on_error MyCustomError do |step, opts, error| - # nesting pipelines also works - pipeline(:error).execute(error) - end - end - - pipeline :error do |p| - p.step do |_, error| - error # do something here - end - end - - def call(arg) - # execute a pipeline simply by fetching it and calling execute on it as you would normally - pipeline(:execution).execute(arg: arg) - end -end -``` ## Topics - Step orchestration (chainable steps) - Constructors should take arg as first and step as second arg