Class: CIA::Event

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
SourceValidation
Defined in:
lib/cia/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SourceValidation

included

Class Method Details

.previousObject



12
13
14
# File 'lib/cia/event.rb', line 12

def self.previous
  scoped(:order => "created_at desc")
end

Instance Method Details

#add_attribute_changes(changes) ⇒ Object

tested via transaction_test.rb



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cia/event.rb', line 23

def add_attribute_changes(changes)
  changes.each do |attribute_name, (old_value, new_value)|
    attribute_changes.build(
      :event => self,
      :attribute_name => attribute_name,
      :old_value => old_value,
      :new_value => new_value,
      :source => source
    )
  end
end

#attribute_change_hashObject



16
17
18
19
20
# File 'lib/cia/event.rb', line 16

def attribute_change_hash
  attribute_changes.inject({}) do |h, a|
    h[a.attribute_name] = [a.old_value, a.new_value]; h
  end
end

#source_must_be_present?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cia/event.rb', line 35

def source_must_be_present?
  new_record? and action != "destroy" and (!attributes.key?("source_display_name") or source_display_name.blank?)
end