Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove duplicated code in the AR::Store.

  • Loading branch information...
commit 6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07 1 parent a734902
@kennyj authored
Showing with 3 additions and 11 deletions.
  1. +3 −11 activerecord/lib/active_record/store.rb
View
14 activerecord/lib/active_record/store.rb
@@ -77,16 +77,8 @@ def store_accessor(store_attribute, *keys)
private
def initialize_store_attribute(store_attribute)
- case attribute = send(store_attribute)
- when ActiveSupport::HashWithIndifferentAccess
- # Already initialized. Do nothing.
- when Hash
- # Initialized as a Hash. Convert to indifferent access.
- send :"#{store_attribute}=", attribute.with_indifferent_access
- else
- # Uninitialized. Set to an indifferent hash.
- send :"#{store_attribute}=", ActiveSupport::HashWithIndifferentAccess.new
- end
+ attr = send(store_attribute)
+ send :"#{store_attribute}=", IndifferentCoder.as_indifferent_hash(attr) unless attr.is_a?(HashWithIndifferentAccess)
end
class IndifferentCoder
@@ -109,7 +101,7 @@ def load(yaml)
def self.as_indifferent_hash(obj)
case obj
- when ActiveSupport::HashWithIndifferentAccess
+ when HashWithIndifferentAccess
obj
when Hash
obj.with_indifferent_access
Please sign in to comment.
Something went wrong with that request. Please try again.