Class: Workflows::Step
- Inherits:
-
Object
- Object
- Workflows::Step
- Defined in:
- lib/workflows/step.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#service_obj ⇒ Object
readonly
Returns the value of attribute service_obj.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #get_output ⇒ Object
- #get_state ⇒ Object
-
#initialize(args = {}) ⇒ Step
constructor
A new instance of Step.
- #run ⇒ Object
- #set_args(args) ⇒ Object
- #set_state(state) ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/workflows/step.rb', line 13 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
13 14 15 |
# File 'lib/workflows/step.rb', line 13 def output @output end |
#service_obj ⇒ Object (readonly)
Returns the value of attribute service_obj.
13 14 15 |
# File 'lib/workflows/step.rb', line 13 def service_obj @service_obj end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
13 14 15 |
# File 'lib/workflows/step.rb', line 13 def state @state end |
#status ⇒ Object (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_output ⇒ Object
51 52 53 |
# File 'lib/workflows/step.rb', line 51 def get_output service_obj.get_output end |
#get_state ⇒ Object
47 48 49 |
# File 'lib/workflows/step.rb', line 47 def get_state service_obj.get_state end |
#run ⇒ Object
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. 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 |