lib/ruote/svc/dollar_sub.rb in ruote-2.2.0 vs lib/ruote/svc/dollar_sub.rb in ruote-2.3.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -23,11 +23,10 @@ #++ require 'rufus/dollar' # gem 'rufus-dollar' require 'ruote/svc/treechecker' -require 'ruote/util/lookup' module Ruote # @@ -63,14 +62,12 @@ text.collect { |e| s(e, flow_expression, workitem) } elsif text.is_a?(Hash) - text.inject({}) { |h, (k, v)| - + text.remap { |(k, v), h| h[s(k, flow_expression, workitem)] = s(v, flow_expression, workitem) - h } else text @@ -88,11 +85,11 @@ protected # If the final text is of the form "$f:x" or "$v:y" will lookup the # x field or the y variable. If the lookup is successful (not nil) will - # return the, not the text. + # return the value, not the text (the value.to_s). # def literal_sub(s, fexp, wi) result = case s when /^\$([^{}:])$/, /^\$(?:field|fld|f):([^{}]+)$/ @@ -121,13 +118,13 @@ class Dict attr_reader :fexp attr_reader :workitem - def initialize(flowexpression, workitem) + def initialize(flow_expression, workitem) - @fexp = flowexpression + @fexp = flow_expression @workitem = workitem end def [](key) @@ -135,9 +132,14 @@ 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