Module: TrackHistory::HistoryMethods

Defined in:
lib/track_history/history_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#historical_action_fieldObject (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_fieldsObject (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, options = {}, &block) # haha
  options.assert_valid_keys(:as)
  save_as = options.has_key?(:as) ? options[: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, options = {})
  options.assert_valid_keys(:before, :after)
  field_s = field.is_a?(String) ? field : field.to_s
  historical_fields[field_s] = { 
    :before => options[:before] || nil,
    :after => options[:after] || nil
  }
  nil
end

#historical_tracksObject



15
16
17
# File 'lib/track_history/history_methods.rb', line 15

def historical_tracks
  @historical_tracks ||= {}
end

#track_historical_reference?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/track_history/history_methods.rb', line 7

def track_historical_reference?
  @track_historical_reference
end