Class: AuditLoggable::ChangeSet::AttributesFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/audit_loggable/change_set.rb

Constant Summary collapse

IGNORED_ATTRIBUTES =
%w[created_at updated_at created_on updated_on].freeze

Instance Method Summary collapse

Constructor Details

#initialize(klass, ignored_attributes, changes) ⇒ AttributesFilter

Returns a new instance of AttributesFilter.



8
9
10
11
12
# File 'lib/audit_loggable/change_set.rb', line 8

def initialize(klass, ignored_attributes, changes)
  @klass = klass
  @ignored_attributes = ignored_attributes
  @changes = changes
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/audit_loggable/change_set.rb', line 14

def call
  @changes
    .except(
      @klass.primary_key,
      @klass.inheritance_column,
      @klass.locking_column,
      *@ignored_attributes,
      *IGNORED_ATTRIBUTES
    )
end