Module: Relational::Audit::ClassMethod

Defined in:
lib/relational/audit.rb

Instance Method Summary collapse

Instance Method Details

#audit_entitiesObject



134
135
136
# File 'lib/relational/audit.rb', line 134

def audit_entities
  self.class_variable_get :@@audit_entities
end

#audit_entities=(audit_entities) ⇒ Object



138
139
140
# File 'lib/relational/audit.rb', line 138

def audit_entities=(audit_entities)
  self.class_variable_set :@@audit_entities, (audit_entities.is_a?(Array) ? audit_entities : [audit_entities])
end

#audit_optionsObject



142
143
144
# File 'lib/relational/audit.rb', line 142

def audit_options
  self.class_variable_get :@@audit_options
end

#audit_options=(audit_options) ⇒ Object



146
147
148
# File 'lib/relational/audit.rb', line 146

def audit_options=(audit_options)
  self.class_variable_set :@@audit_options, audit_options
end

#belongs_to_audit(audit_entities, audit_options = {}) ⇒ Object



158
159
160
161
162
163
164
165
# File 'lib/relational/audit.rb', line 158

def belongs_to_audit audit_entities, audit_options={}
  self.audit_entities = audit_entities
  self.audit_options = audit_options unless audit_options.blank?

  after_create :add_created_child_audit
  after_update :add_updated_child_audit
  after_destroy :add_destroyed_child_audit
end

#relational_audit(audit_options = {}) ⇒ Object



150
151
152
153
154
155
156
# File 'lib/relational/audit.rb', line 150

def relational_audit audit_options={}
  self.audit_options = audit_options unless audit_options.blank?

  after_create :add_created_relational_audit
  after_update :add_updated_relational_audit
  after_destroy :add_destroyed_relational_audit
end