Module: TrackHistory::HistoryMethods
- Defined in:
- lib/track_history/history_methods.rb
Instance Attribute Summary collapse
-
#historical_action_field ⇒ Object
readonly
Returns the value of attribute historical_action_field.
-
#historical_fields ⇒ Object
readonly
Returns the value of attribute historical_fields.
Instance Method Summary collapse
-
#annotate(field, options = {}, &block) ⇒ Object
haha.
- #field(field, options = {}) ⇒ Object
- #historical_tracks ⇒ Object
- #track_historical_reference? ⇒ Boolean
Instance Attribute Details
#historical_action_field ⇒ Object (readonly)
Returns the value of attribute historical_action_field.
5 6 7 |
# File 'lib/track_history/history_methods.rb', line 5 def historical_action_field @historical_action_field end |
#historical_fields ⇒ Object (readonly)
Returns the value of attribute historical_fields.
5 6 7 |
# File 'lib/track_history/history_methods.rb', line 5 def historical_fields @historical_fields end |
Instance Method Details
#annotate(field, options = {}, &block) ⇒ Object
haha
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/track_history/history_methods.rb', line 29 def annotate(field, = {}, &block) # haha .assert_valid_keys(:as) save_as = .has_key?(:as) ? [:as] : field unless columns_hash.has_key?(save_as.to_s) raise ActiveRecord::StatementInvalid.new("No such attribute '#{save_as}' on #{self.name}") end historical_tracks[save_as] = block.nil? ? field : block end |
#field(field, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/track_history/history_methods.rb', line 19 def field(field, = {}) .assert_valid_keys(:before, :after) field_s = field.is_a?(String) ? field : field.to_s historical_fields[field_s] = { :before => [:before] || nil, :after => [:after] || nil } nil end |
#historical_tracks ⇒ Object
15 16 17 |
# File 'lib/track_history/history_methods.rb', line 15 def historical_tracks @historical_tracks ||= {} end |
#track_historical_reference? ⇒ Boolean
7 8 9 |
# File 'lib/track_history/history_methods.rb', line 7 def track_historical_reference? @track_historical_reference end |