module FrozenRecord::Compact
Public Class Methods
new(attrs = {})
click to toggle source
# File lib/frozen_record/compact.rb, line 45 def initialize(attrs = {}) self.attributes = attrs end
Public Instance Methods
[](attr)
click to toggle source
# File lib/frozen_record/compact.rb, line 55 def [](attr) if var = self.class._attributes_cache[attr] instance_variable_get(var) end end
attributes()
click to toggle source
# 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
Private Instance Methods
attribute?(attribute_name)
click to toggle source
# File lib/frozen_record/compact.rb, line 69 def attribute?(attribute_name) val = self[attribute_name] !Base::FALSY_VALUES.include?(val) && val.present? end
attributes=(attributes)
click to toggle source
# File lib/frozen_record/compact.rb, line 63 def attributes=(attributes) self.class.attributes.each do |attr| instance_variable_set(self.class._attributes_cache[attr], attributes[attr]) end end