Module: AuditTables
- Defined in:
- lib/audit_tables.rb,
lib/audit_tables/base.rb,
lib/audit_tables/version.rb,
lib/audit_tables/change_audit_table.rb,
lib/audit_tables/build_audit_trigger.rb,
lib/audit_tables/create_new_audit_table.rb,
lib/audit_tables/create_audit_tables_for_existing_tables.rb
Defined Under Namespace
Classes: Base, BuildAuditTrigger, ChangeAuditTable, Configuration, CreateAuditTablesForExistingTables, CreateNewAuditTable
Constant Summary
collapse
- VERSION =
'1.0.2'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
12
13
14
|
# File 'lib/audit_tables.rb', line 12
def configuration
@configuration
end
|
Class Method Details
.all_audit_tables ⇒ Object
32
33
34
35
36
37
|
# File 'lib/audit_tables.rb', line 32
def self.all_audit_tables
tables = ActiveRecord::Base.connection.tables
tables -= config.exclude_tables
tables
end
|
.build_audit_triggers_for(table_name) ⇒ Object
.change_audit_table_for(table_name) ⇒ Object
61
62
63
|
# File 'lib/audit_tables.rb', line 61
def self.change_audit_table_for(table_name)
AuditTables::ChangeAuditTable.new(table_name.to_s).execute
end
|
.check_for_audit_tables ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/audit_tables.rb', line 43
def self.check_for_audit_tables
messages = []
all_audit_tables.reject { |table| table.starts_with?('audit_') }.each do |table_name|
messages << table_name unless all_audit_tables.include? "audit_#{table_name}"
end
messages
end
|
.config ⇒ Object
23
24
25
|
# File 'lib/audit_tables.rb', line 23
def self.config
self.configuration ||= Configuration.new
end
|
27
28
29
30
|
# File 'lib/audit_tables.rb', line 27
def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end
|
.create_audit_table_for(table_name) ⇒ Object
.create_audit_tables_for_existing_tables ⇒ Object
.rebuild_all_audit_triggers ⇒ Object
65
66
67
68
69
|
# File 'lib/audit_tables.rb', line 65
def self.rebuild_all_audit_triggers
all_audit_tables.reject { |table| table.starts_with?('audit_') }.each do |table_name|
build_audit_triggers_for(table_name)
end
end
|