lib/ruote/workitem.rb in ruote-2.1.9 vs lib/ruote/workitem.rb in ruote-2.1.10

- old
+ new

@@ -41,17 +41,51 @@ def initialize (h) @h = h class << @h; include Ruote::HashDot; end + + #class << @h['fields'] + # alias_method :__get, :[] + # alias_method :__set, :[]= + # def [] (key) + # __get(key.to_s) + # end + # def []= (key, value) + # __set(key.to_s, value) + # end + #end + # indifferent access, not activated for now end + # Returns the underlying Hash instance. + # def to_h @h end + # Returns the String id for this workitem (something like + # "0_0!!20100507-wagamama"). + # + # It's in fact a shortcut for + # + # Ruote::FlowExpressionId.to_storage_id(h.fei) + # + def sid + + Ruote::FlowExpressionId.to_storage_id(h.fei) + end + + # Returns the "workflow instance id" (unique process instance id) of + # the process instance which issued this workitem. + # + def wfid + + h.fei['wfid'] + end + # Returns a Ruote::FlowExpressionId instance. # def fei FlowExpressionId.new(h.fei) @@ -167,9 +201,39 @@ # field and set its value to "Pleasantville". # def set_field (key, value) Ruote.set(@h['fields'], key, value) + end + + # Shortcut for wi.fields['__timed_out__'] + # + def timed_out + + @h['fields']['__timed_out__'] + end + + # Shortcut for wi.fields['__error__'] + # + def error + + @h['fields']['__error__'] + end + + # Shortcut for wi.fields['params'] + # + # When a participant is invoked like in + # + # participant :ref => 'toto', :task => 'x" + # + # then + # + # p workitem.params + # # => { 'ref' => 'toto', 'task' => 'x' } + # + def params + + @h['fields']['params'] end end end