Skip to content

Commit

Permalink
Merge pull request #1 from DrillingInfo/remove-attribute-caching
Browse files Browse the repository at this point in the history
Remove the lookup_cache.
  • Loading branch information
Clark Archer committed Jun 15, 2012
2 parents d277928 + 7025d5d commit 0751ba2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions libraries/bag_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class NodeOverride
def initialize(node, recipe)
@node = node
@recipe = recipe
@@lookup_cache ||= {}
end

# key:: base key accessing attributes
Expand Down Expand Up @@ -104,9 +103,7 @@ def lookup_allowed?(key)
# Returns attribute with bag overrides if applicable
def [](key)
key = key.to_sym if key.respond_to?(:to_sym)
if(@@lookup_cache[key])
@@lookup_cache[key]
elsif(!key.to_s.empty?)
if(!key.to_s.empty?)
val = data_bag_item(key) if lookup_allowed?(key)
if(val)
val.delete('id')
Expand All @@ -121,7 +118,7 @@ def [](key)
)
res = atr[key]
end
@@lookup_cache[key] = res || node[key]
res || node[key]
end
end

Expand All @@ -131,9 +128,6 @@ def method_missing(symbol, *args)
@node.send(symbol, *args)
else
if(symbol.to_s.end_with?('='))
if(@@lookup_cache.has_key?(k = symbol.to_s.sub('=', '').to_sym))
@lookup_cache.delete(k)
end
node.send(symbol, *args)
else
self[args.first]
Expand Down

0 comments on commit 0751ba2

Please sign in to comment.