Class: ActiveRecord::WhenChange::ChangedAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/when_change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr, old_attr, current) ⇒ ChangedAttributes

Returns a new instance of ChangedAttributes.



45
46
47
48
49
# File 'lib/active_record/when_change.rb', line 45

def initialize attr, old_attr, current
  @attr = attr
  @old_attr = old_attr
  @current = current
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



44
45
46
# File 'lib/active_record/when_change.rb', line 44

def attr
  @attr
end

#currentObject (readonly)

Returns the value of attribute current.



44
45
46
# File 'lib/active_record/when_change.rb', line 44

def current
  @current
end

#old_attrObject (readonly)

Returns the value of attribute old_attr.



44
45
46
# File 'lib/active_record/when_change.rb', line 44

def old_attr
  @old_attr
end

Instance Method Details

#inspectObject



51
52
53
# File 'lib/active_record/when_change.rb', line 51

def inspect
  old != value
end

#new_valueObject



67
68
69
# File 'lib/active_record/when_change.rb', line 67

def new_value
  value
end

#oldObject



55
56
57
# File 'lib/active_record/when_change.rb', line 55

def old
  old_attr[attr]
end

#old_valueObject



63
64
65
# File 'lib/active_record/when_change.rb', line 63

def old_value
  old
end

#valueObject



59
60
61
# File 'lib/active_record/when_change.rb', line 59

def value
  current.read_attribute attr
end