Module: AdequateSerialization::CacheBusting

Included in:
AdequateSerialization
Defined in:
lib/adequate_serialization/rails/cache_busting.rb

Defined Under Namespace

Modules: NullAssociation Classes: ActiveJobNotFoundError, InverseNotFoundError, TouchNotFoundError

Instance Method Summary collapse

Instance Method Details

#attribute(*names, &block) ⇒ Object

Overrides the previous ‘attribute` declaration to add some addition validation in the case that we’re serializing an ActiveRecord object.



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/adequate_serialization/rails/cache_busting.rb', line 107

def attribute(*names, &block)
  record = serializes

  if record < ActiveRecord::Base
    (names.last.is_a?(Hash) ? names[0..-2] : names).each do |attribute|
      (record.reflect_on_association(attribute) || NullAssociation).setup
    end
  end

  super
end