module ActiveRecord::Has::SparseAttributes::InstanceMethods
Attributes
sparse_attribute_storage[RW]
Public Instance Methods
get_sparse_attribute(name)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 85 def get_sparse_attribute(name) self.get_sparse_attribute_storage(name).get(name) end
get_sparse_attributes()
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 76 def get_sparse_attributes() r = {} self.class.sparse_attributes.each_key do |k| v = self.get_sparse_attribute(k) r[k] = v unless v.nil? end return r end
set_sparse_attribute(name, value)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 89 def set_sparse_attribute(name, value) self.get_sparse_attribute_storage(name).set(name, value) end
Protected Instance Methods
create_sparse_attribute_storage()
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 102 def create_sparse_attribute_storage() if self.sparse_attribute_storage.nil? self.sparse_attribute_storage = [] self.class.sparse_attribute_storage_configs.each do |config| self.sparse_attribute_storage << config.instance(self) end end end
get_sparse_attribute_storage(name)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 97 def get_sparse_attribute_storage(name) create_sparse_attribute_storage() self.sparse_attribute_storage[self.class.sparse_attributes[name.to_sym]] end
sparse_attributes_after_save(*args)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 125 def sparse_attributes_after_save(*args) create_sparse_attribute_storage() self.sparse_attribute_storage.each do |store| store.after_save(*args) end end
sparse_attributes_before_save(*args)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 118 def sparse_attributes_before_save(*args) create_sparse_attribute_storage() self.sparse_attribute_storage.each do |store| store.before_save(*args) end end
sparse_attributes_before_update(*args)
click to toggle source
# File lib/active_record/has/sparse_attributes.rb, line 111 def sparse_attributes_before_update(*args) create_sparse_attribute_storage() self.sparse_attribute_storage.each do |store| store.before_update(*args) end end