Skip to content
Browse files

moved data magic datastore to global variable

  • Loading branch information...
1 parent 9278b9c commit ade0d937a054fb35ceb064edc1c89a4c5c061188 @cheezy committed Jul 16, 2013
Showing with 15 additions and 3 deletions.
  1. +15 −3 lib/data_magic/translation.rb
View
18 lib/data_magic/translation.rb
@@ -271,15 +271,27 @@ def mask(value)
private
def set_index_variable(ary, value)
- parent.instance_variable_set(index_name(ary), value)
+ index_hash[index_name(ary)] = value
end
def index_variable_for(ary)
- parent.instance_variable_get(index_name(ary))
+ value = index_hash[index_name(ary)]
+ index_hash[index_name(ary)] = -1 unless value
+ index_hash[index_name(ary)]
end
def index_name(ary)
- "@private_#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
+ "#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
+ end
+
+ def index_hash
+ dh = data_hash[parent]
+ data_hash[parent] = {} unless dh
+ data_hash[parent]
+ end
+
+ def data_hash
+ $data_magic_data_hash ||= {}
end
def process(value)

0 comments on commit ade0d93

Please sign in to comment.
Something went wrong with that request. Please try again.