Class: AuditTables::ChangeAuditTable
- Defined in:
- lib/audit_tables/change_audit_table.rb
Instance Attribute Summary collapse
-
#audit_column ⇒ Object
Returns the value of attribute audit_column.
Attributes inherited from Base
#audit_table_name, #column, #klass, #table_name
Instance Method Summary collapse
- #audit_changes ⇒ Object
- #change_attribute ⇒ Object
- #execute ⇒ Object
- #find_column(column) ⇒ Object
-
#properties_curator ⇒ Object
rubocop:disable Metrics/AbcSize:.
-
#remove_attribute ⇒ Object
rubocop:enable Metrics/AbcSize:.
Methods inherited from Base
Constructor Details
This class inherits a constructor from AuditTables::Base
Instance Attribute Details
#audit_column ⇒ Object
Returns the value of attribute audit_column.
4 5 6 |
# File 'lib/audit_tables/change_audit_table.rb', line 4 def audit_column @audit_column end |
Instance Method Details
#audit_changes ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/audit_tables/change_audit_table.rb', line 6 def audit_changes columns(audit_table_name).each do |audit_column| @audit_column = audit_column column_exists?(table_name, audit_column.name) ? change_attribute : remove_attribute end end |
#change_attribute ⇒ Object
14 15 16 |
# File 'lib/audit_tables/change_audit_table.rb', line 14 def change_attribute change_column audit_table_name, column_name, column_type, properties_curator if properties_curator.count.positive? end |
#execute ⇒ Object
18 19 20 21 |
# File 'lib/audit_tables/change_audit_table.rb', line 18 def execute audit_columns audit_changes end |
#find_column(column) ⇒ Object
23 24 25 |
# File 'lib/audit_tables/change_audit_table.rb', line 23 def find_column(column) columns(table_name).each { |col| @column = col if column.name == col.name } end |
#properties_curator ⇒ Object
rubocop:disable Metrics/AbcSize:
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/audit_tables/change_audit_table.rb', line 28 def properties_curator elements = {} find_column(audit_column) elements[:limit] = limit unless audit_column.limit == limit elements[:precision] = precision unless audit_column.precision == precision elements[:scale] = scale unless audit_column.scale == scale elements[:null] = null unless audit_column.null == null elements[:default] = default unless audit_column.default == default elements end |
#remove_attribute ⇒ Object
rubocop:enable Metrics/AbcSize:
42 43 44 |
# File 'lib/audit_tables/change_audit_table.rb', line 42 def remove_attribute remove_column audit_table_name, audit_column.name unless audit_column.name.include? 'audit' end |