Class: Oujoke::Workflow::Base
- Inherits:
-
Object
- Object
- Oujoke::Workflow::Base
- Defined in:
- lib/workflow/base.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
Class Method Summary collapse
Instance Method Summary collapse
- #call_parser_stack ⇒ Object
- #callable_transition ⇒ Object
-
#current_state ⇒ Object
Return current state.
- #current_state=(v) ⇒ Object
-
#initialize(base_obj) ⇒ Base
constructor
A new instance of Base.
- #initiator_email ⇒ Object
- #initiator_email=(v) ⇒ Object
-
#persistanse_data ⇒ Object
Return current business process data as json.
-
#states ⇒ Object
Get all states in ordered position.
- #to_state(state) ⇒ Object
- #transition_params(transition_name, params) ⇒ Object
- #transitions ⇒ Object
Constructor Details
#initialize(base_obj) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 |
# File 'lib/workflow/base.rb', line 11 def initialize(base_obj) @raw_obj = base_obj @attributes = {} @transitions = [] call_parser_stack end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/workflow/base.rb', line 4 def attributes @attributes end |
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
5 6 7 |
# File 'lib/workflow/base.rb', line 5 def invoice_id @invoice_id end |
Class Method Details
.construct(json_obj) ⇒ Object
7 8 9 |
# File 'lib/workflow/base.rb', line 7 def self.construct(json_obj) new(json_obj) end |
Instance Method Details
#call_parser_stack ⇒ Object
74 75 76 77 78 79 |
# File 'lib/workflow/base.rb', line 74 def call_parser_stack @attributes = ActiveSupport::JSON.decode(@raw_obj) @attributes["data"]["transitions"].each do |t| @transitions << "Oujoke::Workflow::#{t["name"].camelize}".constantize.new(self,t) end end |
#callable_transition ⇒ Object
59 60 61 |
# File 'lib/workflow/base.rb', line 59 def callable_transition @transitions.detect{|t| t.from_state == current_state } end |
#current_state ⇒ Object
Return current state
41 42 43 |
# File 'lib/workflow/base.rb', line 41 def current_state @attributes["data"]["current_state"] end |
#current_state=(v) ⇒ Object
45 46 47 |
# File 'lib/workflow/base.rb', line 45 def current_state=(v) @attributes["data"]["current_state"] = v end |
#initiator_email ⇒ Object
31 32 33 |
# File 'lib/workflow/base.rb', line 31 def initiator_email @attributes["data"]["initiator_email"] end |
#initiator_email=(v) ⇒ Object
27 28 29 |
# File 'lib/workflow/base.rb', line 27 def initiator_email=(v) @attributes["data"]["initiator_email"] = v end |
#persistanse_data ⇒ Object
Return current business process data as json
66 67 68 |
# File 'lib/workflow/base.rb', line 66 def persistanse_data @attributes.to_json end |
#states ⇒ Object
Get all states in ordered position
36 37 38 |
# File 'lib/workflow/base.rb', line 36 def states @attributes["data"]["states"] end |
#to_state(state) ⇒ Object
70 71 72 |
# File 'lib/workflow/base.rb', line 70 def to_state(state) end |
#transition_params(transition_name, params) ⇒ Object
49 50 51 52 53 |
# File 'lib/workflow/base.rb', line 49 def transition_params(transition_name , params) @attributes["data"]["transitions"].each do |t| t["params"] = params if t["name"] = transaction_name end end |
#transitions ⇒ Object
55 56 57 |
# File 'lib/workflow/base.rb', line 55 def transitions @transitions end |