Parent

Class/Module Index [+]

Quicksearch

Ruote::Dollar::Dict

Wrapping a flow expression and the current workitem as a Hash-like object ready for lookup at substitution time.

Attributes

fexp[R]
workitem[R]

Public Class Methods

new(flow_expression, workitem) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 120
def initialize(flow_expression, workitem)

  @fexp = flow_expression
  @workitem = workitem
end

Public Instance Methods

[](key) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 126
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) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 155
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) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 170
def has_key?(key)

  pr, k = extract_prefix(key)

  return true if pr == 'r'

  (self[key] != nil)
end

Protected Instance Methods

extract_prefix(key) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 191
def extract_prefix(key)

  i = key.index(':')

  return [ 'f', key ] if not i
    # 'f' is the default prefix (field, not variable)

  pr = key[0..i-1] # until ':'
  pr = pr[0, 2] # the first two chars

  pr = pr[0, 1] unless (pr == 'vf') or (pr == 'fv')

  [ pr, key[i+1..-1] ]
end
lookup(pr, key) click to toggle source
# File lib/ruote/svc/dollar_sub.rb, line 181
def lookup(pr, key)

  case pr
    when 'v' then @fexp.lookup_variable(key)
    when 'f' then Ruote.lookup(@workitem['fields'], key)
    when 'r' then ruby_eval(key)
    else nil
  end
end
ruby_eval(ruby_code) click to toggle source

TODO : rdoc me

# File lib/ruote/svc/dollar_sub.rb, line 208
def ruby_eval(ruby_code)

  raise ArgumentError.new(
    "'ruby_eval_allowed' is set to false, cannot evaluate >" +
    ruby_code +
    "< (http://ruote.rubyforge.org/dollar.html)"
  ) if @fexp.context['ruby_eval_allowed'] != true

  @fexp.context.treechecker.dollar_check(ruby_code)

  RubyContext.new(self).instance_eval(ruby_code)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.