Module: FrozenRecord::Compact

Extended by:
ActiveSupport::Concern
Defined in:
lib/frozen_record/compact.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#[](attr) ⇒ Object



55
56
57
58
59
# File 'lib/frozen_record/compact.rb', line 55

def [](attr)
  if var = self.class._attributes_cache[attr]
    instance_variable_get(var)
  end
end

#attributesObject



49
50
51
52
53
# File 'lib/frozen_record/compact.rb', line 49

def attributes
  self.class.attributes.each_with_object({}) do |attr, hash|
    hash[attr] = self[attr]
  end
end

#initialize(attrs = {}) ⇒ Object



45
46
47
# File 'lib/frozen_record/compact.rb', line 45

def initialize(attrs = {})
  self.attributes = attrs
end