Class: ActiveRecord::Store::HashAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/store.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.prepare(object, attribute) ⇒ Object



234
235
236
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/store.rb', line 234

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

.read(object, attribute, key) ⇒ Object



221
222
223
224
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/store.rb', line 221

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

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



226
227
228
229
230
231
232
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/store.rb', line 226

def self.write(object, attribute, key, value)
  prepare(object, attribute)
  if value != read(object, attribute, key)
    object.public_send :"#{attribute}_will_change!"
    object.public_send(attribute)[key] = value
  end
end