Class: Dunlop::AttributeChangesTracking::LastChanged
- Inherits:
-
Object
- Object
- Dunlop::AttributeChangesTracking::LastChanged
- Defined in:
- app/models/dunlop/attribute_changes_tracking.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #[](val) ⇒ Object
-
#initialize(target) ⇒ LastChanged
constructor
A new instance of LastChanged.
- #method_missing(m, *args) ⇒ Object
Constructor Details
#initialize(target) ⇒ LastChanged
Returns a new instance of LastChanged.
40 41 42 |
# File 'app/models/dunlop/attribute_changes_tracking.rb', line 40 def initialize(target) @target = target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
44 45 46 47 |
# File 'app/models/dunlop/attribute_changes_tracking.rb', line 44 def method_missing(m, *args) raise "#{target.class.name} has no attribute #{m}" unless target.has_attribute?(m) self[m] end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
39 40 41 |
# File 'app/models/dunlop/attribute_changes_tracking.rb', line 39 def target @target end |
Instance Method Details
#[](val) ⇒ Object
49 50 51 |
# File 'app/models/dunlop/attribute_changes_tracking.rb', line 49 def [](val) target.last_attribute_changes.find{|changed| changed.attribute_name == val.to_s }.try(:changed_at) end |