Module: SafeAttributes::Base

Extended by:
ActiveSupport::Concern
Included in:
SafeAttributes
Defined in:
lib/safe_attributes/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#attribute_change(attr) ⇒ Object



66
67
68
# File 'lib/safe_attributes/base.rb', line 66

def attribute_change(attr)
  [changed_attributes[attr], read_attribute_for_validation(attr)] if attribute_changed?(attr)
end

#read_attribute_for_validation(attr) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/safe_attributes/base.rb', line 58

def read_attribute_for_validation(attr)
  if (self.attributes.include?(attr.to_s))
    self[attr.to_sym]
  else
    self.send(attr.to_s) if (self.respond_to?(attr.to_sym))
  end
end