Class: Ruote::Dollar::Dict
- Inherits:
-
Object
- Object
- Ruote::Dollar::Dict
- Defined in:
- lib/ruote/svc/dollar_sub.rb
Overview
Wrapping a flow expression and the current workitem as a Hash-like object ready for lookup at substitution time.
Instance Attribute Summary collapse
-
#fexp ⇒ Object
readonly
Returns the value of attribute fexp.
-
#workitem ⇒ Object
readonly
Returns the value of attribute workitem.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(flowexpression, workitem) ⇒ Dict
constructor
A new instance of Dict.
Constructor Details
#initialize(flowexpression, workitem) ⇒ Dict
Returns a new instance of Dict.
126 127 128 129 130 |
# File 'lib/ruote/svc/dollar_sub.rb', line 126 def initialize(flowexpression, workitem) @fexp = flowexpression @workitem = workitem end |
Instance Attribute Details
#fexp ⇒ Object (readonly)
Returns the value of attribute fexp.
123 124 125 |
# File 'lib/ruote/svc/dollar_sub.rb', line 123 def fexp @fexp end |
#workitem ⇒ Object (readonly)
Returns the value of attribute workitem.
124 125 126 |
# File 'lib/ruote/svc/dollar_sub.rb', line 124 def workitem @workitem end |
Instance Method Details
#[](key) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ruote/svc/dollar_sub.rb', line 132 def [](key) return @fexp.fei.to_storage_id if key == 'fei' return @fexp.fei.wfid if key == 'wfid' return @fexp.fei.subid if key == 'subid' return @fexp.fei.subid if key == 'sub_wfid' # deprecated in 2.1.12 return @fexp.fei.expid if key == 'expid' return @fexp.fei.engine_id if key == 'engine_id' pr, k = extract_prefix(key) # stage 0 v = lookup(pr[0, 1], k) return v if v != nil # stage 1 return '' if pr.size < 2 lookup(pr[1, 1], k) end |
#[]=(key, value) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ruote/svc/dollar_sub.rb', line 156 def []=(key, value) pr, k = extract_prefix(key) pr = pr[0, 1] if pr == 'f' @workitem.set_attribute(k, value) elsif @fexp @fexp.set_variable(k, value) end end |
#has_key?(key) ⇒ Boolean
171 172 173 174 175 176 177 178 |
# File 'lib/ruote/svc/dollar_sub.rb', line 171 def has_key?(key) pr, k = extract_prefix(key) return true if pr == 'r' (self[key] != nil) end |