Module: Auditing::AuditRelationship::InstanceMethods
- Defined in:
- lib/auditing/audit_relationship.rb
Instance Method Summary collapse
- #audit_relationship_create ⇒ Object
- #audit_relationship_destroy ⇒ Object
- #audit_relationship_update ⇒ Object
Instance Method Details
#audit_relationship_create ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/auditing/audit_relationship.rb', line 88 def audit_relationship_create audit_enabled_models.each do |model| return unless send(model).respond_to?('log_association_create') field_names.each do |field| field_value = send(field) next unless field_value.present? model_instance = send(model) model_instance.log_association_create(self, {:field => field, :value => field_value}) end end end |
#audit_relationship_destroy ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/auditing/audit_relationship.rb', line 116 def audit_relationship_destroy audit_enabled_models.each do |model| return unless send(model).respond_to?('log_association_destroy') model_instance = send(model) model_instance.log_association_destroy(self) end end |
#audit_relationship_update ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/auditing/audit_relationship.rb', line 101 def audit_relationship_update if changed? audit_enabled_models.each do |model| return unless send(model).respond_to?('log_association_update') changes.each.select {|k,v| field_names.include?(k)}.each do |field, change| field_value = send(field) model_instance = send(model) model_instance.log_association_update(self, {:field => field, :old_value => change[0], :new_value => change[1]}) end end end end |