Sha256: 75fcb0e27ced4963a3e8db2724a901c1f9643e713a502beb667338272f61bb2e

Contents?: true

Size: 661 Bytes

Versions: 10

Compression:

Stored size: 661 Bytes

Contents

# -*- encoding: utf-8 -*-
module Kasket
  module ReloadAssociationMixin
    def reload_with_kasket_clearing(*args)
      if loaded?
        Kasket.clear_local if target.class.include?(WriteMixin)
      else
        refl = (ActiveRecord::VERSION::MAJOR == 2 || AR30) ? proxy_reflection : reflection
        target_class = (refl.options[:polymorphic] ? (respond_to?(:klass) ? klass : association_class) : refl.klass)
        Kasket.clear_local if target_class && target_class.include?(WriteMixin)
      end

      reload_without_kasket_clearing(*args)
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kasket-3.1.5 lib/kasket/reload_association_mixin.rb
kasket-3.1.4 lib/kasket/reload_association_mixin.rb
kasket-3.1.3 lib/kasket/reload_association_mixin.rb
kasket-3.1.2 lib/kasket/reload_association_mixin.rb
kasket-3.1.1 lib/kasket/reload_association_mixin.rb
kasket-3.1.0 lib/kasket/reload_association_mixin.rb
kasket-3.0.0 lib/kasket/reload_association_mixin.rb
kasket-2.2.1 lib/kasket/reload_association_mixin.rb
kasket-2.2.0 lib/kasket/reload_association_mixin.rb
kasket-2.1.2 lib/kasket/reload_association_mixin.rb