lib/openwfe/expressions/environment.rb in openwferu-0.9.6 vs lib/openwfe/expressions/environment.rb in openwferu-0.9.7
- old
+ new
@@ -51,10 +51,12 @@
# It's an expression as it's storable in the expression pool.
#
class Environment < FlowExpression
include Schedulable
+ names :environment
+
attr_accessor \
:variables
def initialize \
(id, parent, environment_id, application_context, attributes)
@@ -64,57 +66,62 @@
@variables = {}
end
def [] (key)
- if OpenWFE::starts_with(key, "//")
- return get_expression_pool()\
- .get_engine_environment()[key[2..-1]]
- end
- if OpenWFE::starts_with(key, "/")
- return get_root_environment()[key[1..-1]]
- end
+ #if OpenWFE::starts_with(key, "//")
+ # return get_expression_pool()\
+ # .get_engine_environment()[key[2..-1]]
+ #end
+ #if OpenWFE::starts_with(key, "/")
+ # return get_root_environment()[key[1..-1]]
+ #end
value = @variables[key]
return value \
if @variables.has_key?(key) or is_engine_environment?
#if value or is_engine_environment?
- return get_parent()[key] if @parent_id
+ return get_parent[key] if @parent_id
- return get_expression_pool().fetch_engine_environment()[key]
+ return get_expression_pool.fetch_engine_environment[key]
end
def []= (key, value)
- if OpenWFE::starts_with(key, "//")
- key = key[2..-1]
- get_expression_pool().fetch_engine_environment()[key] = value
- elsif OpenWFE::starts_with(key, "/")
- key = key[1..-1]
- get_root_environment()[key] = value
- else
- @variables[key] = value
- store_itself()
+ #if OpenWFE::starts_with(key, "//")
+ # key = key[2..-1]
+ # get_expression_pool().fetch_engine_environment()[key] = value
+ #elsif OpenWFE::starts_with(key, "/")
+ # key = key[1..-1]
+ # get_root_environment()[key] = value
+ #else
+ # @variables[key] = value
+ # store_itself()
+ # #ldebug { "[]= #{@fei.to_debug_s} : '#{key}' -> '#{value}'" }
+ #end
- #ldebug { "[]= #{@fei.to_debug_s} : '#{key}' -> '#{value}'" }
- end
+ @variables[key] = value
+ store_itself()
end
def delete (key)
- if OpenWFE::starts_with(key, "//")
- key = key[2..-1]
- get_expression_pool().fetch_engine_environment().delete(key)
- elsif OpenWFE::starts_with(key, "/")
- key = key[1..-1]
- get_root_environment().delete(key)
- else
- @variables.delete(key)
- store_itself()
- end
+ #if OpenWFE::starts_with(key, "//")
+ # key = key[2..-1]
+ # get_expression_pool().fetch_engine_environment().delete(key)
+ #elsif OpenWFE::starts_with(key, "/")
+ # key = key[1..-1]
+ # get_root_environment().delete(key)
+ #else
+ # @variables.delete(key)
+ # store_itself()
+ #end
+
+ @variables.delete key
+ store_itself()
end
#
# This method is usually called before the environment gets wiped
# out of the expression pool.
@@ -165,16 +172,19 @@
end
store_itself()
end
- protected
+ #
+ # Returns the top environment for the process instance.
+ #
+ def get_root_environment ()
- def get_root_environment ()
- #ldebug { "get_root_environment()\n#{self}" }
- return self if not @parent_id
- return get_parent().get_root_environment()
- end
+ #ldebug { "get_root_environment()\n#{self}" }
+
+ return self if not @parent_id
+ return get_parent().get_root_environment()
+ end
end
end