Class: NoBrainer::Document::Store::HashAccessor

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

Overview

:nodoc:

Direct Known Subclasses

StringKeyedHashAccessor

Class Method Summary collapse

Class Method Details

.prepare(object, attribute) ⇒ Object



258
259
260
# File 'lib/no_brainer/document/store.rb', line 258

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

.read(object, attribute, key) ⇒ Object



244
245
246
247
# File 'lib/no_brainer/document/store.rb', line 244

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

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



249
250
251
252
253
254
255
256
# File 'lib/no_brainer/document/store.rb', line 249

def self.write(object, attribute, key, value)
  prepare(object, attribute)
  if value != read(object, attribute, key)
    # "#{attribute}_will_change!" is not implemented in NoBrainer. See issue #190
    # object.public_send :"#{attribute}_will_change!"
    object.public_send(attribute)[key] = value
  end
end