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(flow_expression, workitem) ⇒ Dict
constructor
A new instance of Dict.
Constructor Details
#initialize(flow_expression, workitem) ⇒ Dict
Returns a new instance of Dict.
123 124 125 126 127 |
# File 'lib/ruote/svc/dollar_sub.rb', line 123 def initialize(flow_expression, workitem) @fexp = flow_expression @workitem = workitem end |
Instance Attribute Details
#fexp ⇒ Object (readonly)
Returns the value of attribute fexp.
120 121 122 |
# File 'lib/ruote/svc/dollar_sub.rb', line 120 def fexp @fexp end |
#workitem ⇒ Object (readonly)
Returns the value of attribute workitem.
121 122 123 |
# File 'lib/ruote/svc/dollar_sub.rb', line 121 def workitem @workitem end |
Instance Method Details
#[](key) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ruote/svc/dollar_sub.rb', line 129 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' return @fexp.fei.mnemo_id if key == 'mnemo_id' return @workitem['fields']['__tags__'] if key == 'tags' return (@workitem['fields']['__tags__'] || []).last if key == 'tag' return (@workitem['fields']['__tags__'] || []).join('/') if key == 'full_tag' 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
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/ruote/svc/dollar_sub.rb', line 158 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
173 174 175 176 177 178 179 180 |
# File 'lib/ruote/svc/dollar_sub.rb', line 173 def has_key?(key) pr, k = extract_prefix(key) return true if pr == 'r' (self[key] != nil) end |