Module: Yesterday::Model::ClassMethods
- Defined in:
- lib/yesterday/model.rb
Instance Method Summary collapse
- #diff_version(from_version_number, to_version_number) ⇒ Object
- #exclude_tracking_for(options) ⇒ Object
- #excluded_tracked_associations ⇒ Object
- #excluded_tracked_attributes ⇒ Object
- #include_tracking_for(options) ⇒ Object
- #track_changes(options = {}) ⇒ Object
- #tracked_associations ⇒ Object
- #tracked_attributes ⇒ Object
- #version(version_number) ⇒ Object
Instance Method Details
#diff_version(from_version_number, to_version_number) ⇒ Object
62 63 64 65 66 |
# File 'lib/yesterday/model.rb', line 62 def diff_version(from_version_number, to_version_number) if object = first Versioning.diff_for from_version_number, to_version_number, object end end |
#exclude_tracking_for(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/yesterday/model.rb', line 9 def exclude_tracking_for() if [:associations] @excluded_tracked_associations ||= [] @excluded_tracked_associations += Array([:associations]).map(&:to_s) end if [:attributes] @excluded_tracked_attributes ||= [] @excluded_tracked_attributes += Array([:attributes]).map(&:to_s) end end |
#excluded_tracked_associations ⇒ Object
33 34 35 |
# File 'lib/yesterday/model.rb', line 33 def excluded_tracked_associations @excluded_tracked_associations || [] end |
#excluded_tracked_attributes ⇒ Object
37 38 39 |
# File 'lib/yesterday/model.rb', line 37 def excluded_tracked_attributes @excluded_tracked_attributes || [] end |
#include_tracking_for(options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yesterday/model.rb', line 21 def include_tracking_for() if [:associations] @tracked_associations ||= [] @tracked_associations += Array([:associations]).map(&:to_s) end if [:attributes] @tracked_attributes ||= [] @tracked_attributes += Array([:attributes]).map(&:to_s) end end |
#track_changes(options = {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/yesterday/model.rb', line 49 def track_changes( = {}) send :include, InstanceMethods after_save :serialize_current_state exclude_tracking_for :associations => :changesets end |
#tracked_associations ⇒ Object
41 42 43 |
# File 'lib/yesterday/model.rb', line 41 def tracked_associations @tracked_associations || [] end |
#tracked_attributes ⇒ Object
45 46 47 |
# File 'lib/yesterday/model.rb', line 45 def tracked_attributes @tracked_attributes || [] end |
#version(version_number) ⇒ Object
56 57 58 59 60 |
# File 'lib/yesterday/model.rb', line 56 def version(version_number) if object = first Versioning.versioned_object_for version_number, object end end |