aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-05-25 09:42:28 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-18 23:54:13 -0300
commit8593964d9741704ff030e3bdf61e0ed64526ecec (patch)
tree6ef5368dd403dfb0d293dc8b8885f7d6d0c92a60 /activerecord/lib
parent757f7231cccd2bcbfb83fba5cb203fb320f3e613 (diff)
downloadrails-8593964d9741704ff030e3bdf61e0ed64526ecec.tar.gz
rails-8593964d9741704ff030e3bdf61e0ed64526ecec.tar.bz2
rails-8593964d9741704ff030e3bdf61e0ed64526ecec.zip
Refactor and use class_attribute
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/store.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index f5c7a9f034..d13491502e 100644
--- a/activerecord/lib/active_record/store.rb
+++ b/activerecord/lib/active_record/store.rb
@@ -1,5 +1,6 @@
require 'active_support/concern'
require 'active_support/core_ext/hash/indifferent_access'
+require 'active_support/core_ext/class/attribute'
module ActiveRecord
# Store gives you a thin wrapper around serialize for the purpose of storing hashes in a single column.
@@ -42,7 +43,7 @@ module ActiveRecord
extend ActiveSupport::Concern
included do
- config_attribute :stored_attributes
+ class_attribute :stored_attributes
self.stored_attributes = {}
end
@@ -53,7 +54,8 @@ module ActiveRecord
end
def store_accessor(store_attribute, *keys)
- keys.flatten.each do |key|
+ keys = keys.flatten
+ keys.each do |key|
define_method("#{key}=") do |value|
initialize_store_attribute(store_attribute)
send(store_attribute)[key] = value
@@ -66,7 +68,7 @@ module ActiveRecord
end
end
- self.stored_attributes[store_attribute] = keys.flatten
+ self.stored_attributes[store_attribute] = keys
end
end