Class: OpenWFE::FlowDict
- Inherits:
-
Object
- Object
- OpenWFE::FlowDict
- Defined in:
- lib/openwfe/util/dollar.rb
Overview
Wrapping a process expression and the current workitem as a Hash object ready for lookup at substitution time.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(flow_expression, workitem, default_prefix = 'v') ⇒ FlowDict
constructor
A new instance of FlowDict.
Constructor Details
#initialize(flow_expression, workitem, default_prefix = 'v') ⇒ FlowDict
Returns a new instance of FlowDict.
73 74 75 76 77 78 |
# File 'lib/openwfe/util/dollar.rb', line 73 def initialize (flow_expression, workitem, default_prefix='v') @flow_expression = flow_expression @workitem = workitem @default_prefix = default_prefix end |
Instance Method Details
#[](key) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/openwfe/util/dollar.rb', line 80 def [] (key) p, k = extract_prefix(key) #puts "### p, k is '#{p}', '#{k}'" return '' if k == '' return @workitem.lookup_attribute(k) if p == 'f' if p == 'v' return '' unless @flow_expression return @flow_expression.lookup_variable(k) end #return call_function(k) if p == 'c' return call_ruby(k) if p == 'r' @workitem.lookup_attribute key end |
#[]=(key, value) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/openwfe/util/dollar.rb', line 101 def []= (key, value) pr, k = extract_prefix(key) if pr == 'f' @workitem.set_attribute k, value elsif @flow_expression @flow_expression.set_variable k, value end end |
#has_key?(key) ⇒ Boolean
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/openwfe/util/dollar.rb', line 115 def has_key? (key) p, k = extract_prefix(key) return false if k == '' return @workitem.has_attribute?(k) if p == 'f' if p == 'v' return false unless @flow_expression return (@flow_expression.lookup_variable(k) != nil) end #return true if p == 'c' return true if p == 'r' @workitem.has_attribute?(key) end |