Module: Shipit::DeferredTouch::ClassMethods

Defined in:
app/models/concerns/shipit/deferred_touch.rb

Instance Method Summary collapse

Instance Method Details

#deferred_touch(touches) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'app/models/concerns/shipit/deferred_touch.rb', line 66

def deferred_touch(touches)
  touches = touches.transform_values(&Array.method(:wrap))
  self.deferred_touches = touches.flat_map do |association_name, attributes|
    association = reflect_on_association(association_name)
    Array.wrap(attributes).map do |attribute|
      [association.klass.name, association.foreign_key, attribute]
    end
  end
end