module ActiveRecord::TypedStore::Behavior

Public Instance Methods

attribute?(attr_name) click to toggle source
Calls superclass method
# File lib/active_record/typed_store/behavior.rb, line 56
def attribute?(attr_name)
  if self.class.store_accessors.include?(attr_name.to_s)
    value = public_send(attr_name)

    case value
    when true        then true
    when false, nil  then false
    else
      if value.respond_to?(:zero?)
        !value.zero?
      else
        !value.blank?
      end
    end
  else
    super
  end
end
changes() click to toggle source
Calls superclass method
# File lib/active_record/typed_store/behavior.rb, line 34
def changes
  changes = super
  self.class.store_accessors.each do |attr|
    if send("#{attr}_changed?")
      changes[attr] = [send("#{attr}_was"), send(attr)]
    end
  end
  changes
end
clear_attribute_change(attr_name) click to toggle source
Calls superclass method
# File lib/active_record/typed_store/behavior.rb, line 44
def clear_attribute_change(attr_name)
  return if self.class.store_accessors.include?(attr_name.to_s)
  super
end
read_attribute(attr_name) click to toggle source
Calls superclass method
# File lib/active_record/typed_store/behavior.rb, line 49
def read_attribute(attr_name)
  if self.class.store_accessors.include?(attr_name.to_s)
    return public_send(attr_name)
  end
  super
end