module FrozenRecord::Compact::ClassMethods
Attributes
_attributes_cache[R]
Public Instance Methods
define_method_attribute(attr, **)
click to toggle source
# File lib/frozen_record/compact.rb, line 28 def define_method_attribute(attr, **) generated_attribute_methods.attr_reader(attr) end
load_records(force: false)
click to toggle source
# File lib/frozen_record/compact.rb, line 8 def load_records(force: false) if force || (auto_reloading && file_changed?) @records = nil undefine_attribute_methods end @records ||= begin records = backend.load(file_path) if attribute_deserializers.any? || default_attributes records = records.map { |r| assign_defaults!(deserialize_attributes!(r.dup)).freeze }.freeze end @attributes = list_attributes(records).freeze build_attributes_cache define_attribute_methods(@attributes.to_a) records = FrozenRecord.ignore_max_records_scan { records.map { |r| load(r) }.freeze } index_definitions.values.each { |index| index.build(records) } records end end
Private Instance Methods
build_attributes_cache()
click to toggle source
# File lib/frozen_record/compact.rb, line 36 def build_attributes_cache @_attributes_cache = @attributes.each_with_object({}) do |attr, cache| var = :"@#{attr}" cache[attr.to_s] = var cache[attr.to_sym] = var end end