Class: AuditLoggable::ChangeSet::EnumAttributesNormalizer
- Inherits:
-
Object
- Object
- AuditLoggable::ChangeSet::EnumAttributesNormalizer
- Defined in:
- lib/audit_loggable/change_set.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(klass, changes) ⇒ EnumAttributesNormalizer
constructor
A new instance of EnumAttributesNormalizer.
Constructor Details
#initialize(klass, changes) ⇒ EnumAttributesNormalizer
Returns a new instance of EnumAttributesNormalizer.
27 28 29 30 |
# File 'lib/audit_loggable/change_set.rb', line 27 def initialize(klass, changes) @klass = klass @changes = changes end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/audit_loggable/change_set.rb', line 32 def call @klass.defined_enums.each_pair.with_object(@changes.dup) do |(name, values), changes| next unless changes.key?(name) changes[name] = if changes[name].is_a? ::Array changes[name].map { |v| values[v] } else changes[name] = values[changes[name]] end end end |