Class: AuditLog::Mapping

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/audit_log/mapping.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMapping

Returns a new instance of Mapping.



14
15
16
# File 'lib/audit_log/mapping.rb', line 14

def initialize
  @audit_mappings = {}
end

Instance Attribute Details

#audit_mappingsObject (readonly)

Returns the value of attribute audit_mappings.



8
9
10
# File 'lib/audit_log/mapping.rb', line 8

def audit_mappings
  @audit_mappings
end

Class Method Details

.prepare(&block) ⇒ Object



10
11
12
# File 'lib/audit_log/mapping.rb', line 10

def self.prepare(&block)
  AuditLog::Mapping.instance.instance_eval(&block)
end

Instance Method Details

#audit(model_class_name, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/audit_log/mapping.rb', line 18

def audit(model_class_name, options = {})
  @audit_mappings[model_class_name] = {
    ignored_fields: options[:ignore] || [],
    nested_audited_models: [],
    controllers: options[:controllers] || [model_class_name]
  }  
  
  @current = @audit_mappings[model_class_name]
  self
end

#join(*nested_audited_models) ⇒ Object



29
30
31
32
# File 'lib/audit_log/mapping.rb', line 29

def join(*nested_audited_models)
  @current[:nested_audited_models] = nested_audited_models
  self
end