Module: EgovUtils::HasAuditTrail::ClassMethods

Defined in:
lib/egov_utils/has_audit_trail.rb

Instance Method Summary collapse

Instance Method Details

#has_audit_trail(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/egov_utils/has_audit_trail.rb', line 10

def has_audit_trail(options = {})
  return if self.included_modules.include?(EgovUtils::HasAuditTrail::AuditTrailMethods)

  default_options = {
    :non_audited_columns => %w(id updated_at created_at lft rgt lock_version),
    :important_columns => [],
    :format_detail_date_columns => [],
    :format_detail_time_columns => [],
    :format_detail_reflection_columns => [],
    :format_detail_boolean_columns => [],
    :format_detail_hours_columns => []
  }

  cattr_accessor :audit_trail_options
  self.audit_trail_options = default_options.dup

  options.each do |k,v|
    self.audit_trail_options[k] = Array(self.audit_trail_options[k]) | v
  end

  send :include, EgovUtils::HasAuditTrail::AuditTrailMethods
end