Class: Opie::Operation

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#containerObject (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

#failObject



36
37
38
# File 'lib/opie/operation.rb', line 36

def fail
  'fail'
end

#failure?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


45
46
47
# File 'lib/opie/operation.rb', line 45

def success?
  !@failure
end