Class: Workflows::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/workflows/step.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Step

Returns a new instance of Step.



19
20
21
22
23
24
25
26
# File 'lib/workflows/step.rb', line 19

def initialize(args = {})
  @name = args[:name]
  @klass = args[:service]
  @strategy = args[:strategy] || :fail
  @service_args = args[:args]

  @service_obj = @klass.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/workflows/step.rb', line 13

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



13
14
15
# File 'lib/workflows/step.rb', line 13

def output
  @output
end

#service_objObject (readonly)

Returns the value of attribute service_obj.



13
14
15
# File 'lib/workflows/step.rb', line 13

def service_obj
  @service_obj
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/workflows/step.rb', line 13

def state
  @state
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/workflows/step.rb', line 13

def status
  @status
end

Class Method Details

.build_all(steps = []) ⇒ Object



7
8
9
10
11
# File 'lib/workflows/step.rb', line 7

def self.build_all(steps = [])
  steps.map do |step_hash|
    new(step_hash)
  end
end

Instance Method Details

#get_outputObject



51
52
53
# File 'lib/workflows/step.rb', line 51

def get_output
  service_obj.get_output
end

#get_stateObject



47
48
49
# File 'lib/workflows/step.rb', line 47

def get_state
  service_obj.get_state
end

#runObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/workflows/step.rb', line 28

def run
  @status = :ok
  service_obj.run
  @output = service_obj.get_output
rescue => e
  @status = :fail
  @output = e.message
ensure
  @state = service_obj.get_state
end

#set_args(args) ⇒ Object



39
40
41
# File 'lib/workflows/step.rb', line 39

def set_args(args)
  service_obj.set_args args
end

#set_state(state) ⇒ Object



43
44
45
# File 'lib/workflows/step.rb', line 43

def set_state(state)
  service_obj.set_state state
end