Module: Railway

Defined Under Namespace

Modules: DSL

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Result::DSL

#Failure, #Success

Class Method Details

.included(base) ⇒ Object


17
18
19
# File 'lib/railway.rb', line 17

def self.included(base)
  base.send :extend, DSL
end

Instance Method Details

#call(input = {}) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/railway.rb', line 21

def call(input = {})
  steps = self.class.steps

  return Failure('No steps') if steps.empty?

  steps.
    inject(Success(input)) {|result, step|
      result.and_then {|data|
        dispatch_step(step, data)
      }
    }
end