Class: ActiveRecord::Store::HashAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/store.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.prepare(object, attribute) ⇒ Object



238
239
240
# File 'lib/active_record/store.rb', line 238

def self.prepare(object, attribute)
  object.public_send :"#{attribute}=", {} unless object.send(attribute)
end

.read(object, attribute, key) ⇒ Object



228
229
230
231
# File 'lib/active_record/store.rb', line 228

def self.read(object, attribute, key)
  prepare(object, attribute)
  object.public_send(attribute)[key]
end

.write(object, attribute, key, value) ⇒ Object



233
234
235
236
# File 'lib/active_record/store.rb', line 233

def self.write(object, attribute, key, value)
  prepare(object, attribute)
  object.public_send(attribute)[key] = value if value != read(object, attribute, key)
end