Class: Opie::Operation
- Inherits:
-
Object
- Object
- Opie::Operation
- Defined in:
- lib/opie/operation.rb
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
Class Method Summary collapse
Instance Method Summary collapse
- #fail ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(params = {}, dependencies = {}) ⇒ Operation
constructor
A new instance of Operation.
-
#success? ⇒ Boolean
def []=(key, value) container.register(key, value) end result, container.
Constructor Details
#initialize(params = {}, dependencies = {}) ⇒ Operation
Returns a new instance of Operation.
7 8 9 10 11 |
# File 'lib/opie/operation.rb', line 7 def initialize(params = {}, dependencies = {}) @container = Dry::Container.new @container.register('params', params) dependencies.each { |k, v| @container.register(k, v) } end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
5 6 7 |
# File 'lib/opie/operation.rb', line 5 def container @container end |
Class Method Details
.call(*args) ⇒ Object
14 15 16 17 18 |
# File 'lib/opie/operation.rb', line 14 def call(*args) instance = self.new(*args) instance.send(:execute_steps, step_list) instance end |
.step(step) ⇒ Object
20 21 22 |
# File 'lib/opie/operation.rb', line 20 def step(step) add_step(step) end |
Instance Method Details
#fail ⇒ Object
36 37 38 |
# File 'lib/opie/operation.rb', line 36 def fail 'fail' end |
#failure? ⇒ Boolean
49 50 51 |
# File 'lib/opie/operation.rb', line 49 def failure? @failure end |
#success? ⇒ Boolean
def []=(key, value)
container.register(key, value)
end result, container
45 46 47 |
# File 'lib/opie/operation.rb', line 45 def success? !@failure end |