lib/openwfe/util/dollar.rb in openwferu-0.9.3 vs lib/openwfe/util/dollar.rb in openwferu-0.9.4
- old
+ new
@@ -48,11 +48,14 @@
module OpenWFE
def OpenWFE.dsub (text, dict)
#puts "### text is >#{text}<"
+ #puts "### dict is of class #{dict.class.name}"
+ #return nil unless text
+
j = text.index("}")
return text if not j
t = text[0, j]
@@ -120,31 +123,41 @@
#puts "### p, k is '#{p}', '#{k}'"
return '' if k == ''
- return @workitem.attributes[k] if p == 'f'
- return @flow_expression.lookup_variable(k) if p == 'v'
+ return @workitem.lookup_attribute(k) if p == 'f'
+
+ if p == 'v'
+ return '' unless @flow_expression
+ return @flow_expression.lookup_variable(k)
+ end
+
return call_function(k) if p == 'c'
return call_ruby(k) if p == 'r'
# TODO : implement constant lookup
- return @workitem.attributes[key]
+ return @workitem.lookup_attribute(key)
end
def has_key? (key)
p, k = extract_prefix(key)
return false if k == ''
- return @workitem.attributes.has_key?(k) if p == 'f'
- return (@flow_expression.lookup_variable(k) != nil) if p == 'v'
+ return @workitem.has_attribute?(k) if p == 'f'
+
+ if p == 'v'
+ return false unless @flow_expression
+ return (@flow_expression.lookup_variable(k) != nil)
+ end
+
return true if p == 'c'
return true if p == 'r'
# TODO : implement constant lookup
- return @workitem.attributes.has_key?(key)
+ return @workitem.has_attribute?(key)
end
protected
def extract_prefix (key)
@@ -157,10 +170,14 @@
#"function '#{function_name}' is not implemented"
"functions are not yet implemented"
end
def call_ruby (ruby_code)
- eval(ruby_code, @flow_expression.get_binding).to_s
+
+ binding = nil
+ binding = @flow_expression.get_binding if @flow_expression
+
+ eval(ruby_code, binding).to_s
end
end
end