Class: Teckel::Operation::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/teckel/operation.rb

Overview

The default implementation for executing a single Teckel::Operation

Direct Known Subclasses

Teckel::Operation::Results::Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ Runner

Returns a new instance of Runner.



99
100
101
# File 'lib/teckel/operation.rb', line 99

def initialize(operation)
  @operation = operation
end

Instance Attribute Details

#operationObject (readonly)

Returns the value of attribute operation.



102
103
104
# File 'lib/teckel/operation.rb', line 102

def operation
  @operation
end

Instance Method Details

#call(input) ⇒ Object



104
105
106
107
108
109
110
111
112
113
# File 'lib/teckel/operation.rb', line 104

def call(input)
  err = catch(:failure) do
    simple_return = UNDEFINED
    out = catch(:success) do
      simple_return = @operation.new.call(build_input(input))
    end
    return simple_return == UNDEFINED ? build_output(*out) : build_output(simple_return)
  end
  build_error(*err)
end