diff options
author | kennyj <kennyj@gmail.com> | 2012-07-07 22:10:01 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2012-08-21 23:40:28 +0900 |
commit | 57bef99073fc2e3e30694bf1fb1a3c04a63bfcff (patch) | |
tree | 74443d08eb3e02752d39a1d19de00d85d8bf0b66 /activerecord/lib/active_record | |
parent | 55d943c5670997ce64744c1ae3cd0426f5517b10 (diff) | |
download | rails-57bef99073fc2e3e30694bf1fb1a3c04a63bfcff.tar.gz rails-57bef99073fc2e3e30694bf1fb1a3c04a63bfcff.tar.bz2 rails-57bef99073fc2e3e30694bf1fb1a3c04a63bfcff.zip |
Use instance_accessor: false instead of instance_writer.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/serialization.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/readonly_attributes.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/store.rb | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb index 33d7cc7f34..bdda5bc009 100644 --- a/activerecord/lib/active_record/attribute_methods/serialization.rb +++ b/activerecord/lib/active_record/attribute_methods/serialization.rb @@ -6,7 +6,7 @@ module ActiveRecord included do # Returns a hash of all the attributes that have been specified for serialization as # keys and their class restriction as values. - class_attribute :serialized_attributes, instance_writer: false + class_attribute :serialized_attributes, instance_accessor: false self.serialized_attributes = {} end @@ -41,6 +41,11 @@ module ActiveRecord end end + def serialized_attributes + ActiveSupport::Deprecation.warn("Instance level serialized_attributes method is deprecated, please use class level method.") + defined?(@serialized_attributes) ? @serialized_attributes : self.class.serialized_attributes + end + class Type # :nodoc: def initialize(column) @column = column @@ -114,7 +119,7 @@ module ActiveRecord end def read_attribute_before_type_cast(attr_name) - if serialized_attributes.include?(attr_name) + if self.class.serialized_attributes.include?(attr_name) super.unserialized_value else super diff --git a/activerecord/lib/active_record/readonly_attributes.rb b/activerecord/lib/active_record/readonly_attributes.rb index 1d8c566e40..b3c20c4aff 100644 --- a/activerecord/lib/active_record/readonly_attributes.rb +++ b/activerecord/lib/active_record/readonly_attributes.rb @@ -4,7 +4,7 @@ module ActiveRecord extend ActiveSupport::Concern included do - class_attribute :_attr_readonly, instance_writer: false + class_attribute :_attr_readonly, instance_accessor: false self._attr_readonly = [] end @@ -20,5 +20,10 @@ module ActiveRecord self._attr_readonly end end + + def _attr_readonly + ActiveSupport::Deprecation.warn("Instance level _attr_readonly method is deprecated, please use class level method.") + defined?(@_attr_readonly) ? @_attr_readonly : self.class._attr_readonly + end end end diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb index 5151f349b7..b4013ecc1e 100644 --- a/activerecord/lib/active_record/store.rb +++ b/activerecord/lib/active_record/store.rb @@ -41,7 +41,7 @@ module ActiveRecord extend ActiveSupport::Concern included do - class_attribute :stored_attributes, instance_writer: false + class_attribute :stored_attributes, instance_accessor: false self.stored_attributes = {} end |