Sha256: 8b519a2b4082a122a6b4d6b71c54be7be3288e5cbd2e6b431516eeffeac6b845

Contents?: true

Size: 622 Bytes

Versions: 1

Compression:

Stored size: 622 Bytes

Contents

module Kasket
  module ReloadAssociationMixin
    def reload_with_kasket_clearing(*args)
      if loaded?
        clear_local_kasket_indices if respond_to?(:clear_local_kasket_indices)
      end

      # or maybe something like this?
      #target_class = proxy_reflection.options[:polymorphic] ? association_class : proxy_reflection.klass
      #Kasket.cache.delete_matched_local(/^#{target_class.kasket_key_prefix}/) if target_class.respond_to?(:kasket_key_prefix)

      reload_without_kasket_clearing(*args)
    end

    def self.included(base)
      base.alias_method_chain :reload, :kasket_clearing
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kasket-0.5.2 lib/kasket/reload_association_mixin.rb