Class: Ruote::Dollar::Dict

Inherits:
Object
  • Object
show all
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)

Instance Method Summary (collapse)

Constructor Details

- (Dict) initialize(flowexpression, workitem)

A new instance of Dict



103
104
105
106
107
# File 'lib/ruote/svc/dollar_sub.rb', line 103

def initialize(flowexpression, workitem)

  @fexp = flowexpression
  @workitem = workitem
end

Instance Attribute Details

- (Object) fexp (readonly)

Returns the value of attribute fexp



100
101
102
# File 'lib/ruote/svc/dollar_sub.rb', line 100

def fexp
  @fexp
end

- (Object) workitem (readonly)

Returns the value of attribute workitem



101
102
103
# File 'lib/ruote/svc/dollar_sub.rb', line 101

def workitem
  @workitem
end

Instance Method Details

- (Object) [](key)



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/ruote/svc/dollar_sub.rb', line 109

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

- (Object) []=(key, value)



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/ruote/svc/dollar_sub.rb', line 133

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

- (Boolean) has_key?(key)

Returns:

  • (Boolean)


148
149
150
151
152
153
154
155
# File 'lib/ruote/svc/dollar_sub.rb', line 148

def has_key?(key)

  pr, k = extract_prefix(key)

  return true if pr == 'r'

  (self[key] != nil)
end