Sha256: 894845b46c24db54347a9b72c8a6eb9a538a8c1bb646fa20081beaafb6936e8d

Contents?: true

Size: 576 Bytes

Versions: 9

Compression:

Stored size: 576 Bytes

Contents

# -*- encoding: utf-8 -*-
module Kasket
  module ReloadAssociationMixin
    # TODO write tests for this
    def reload_with_kasket_clearing(*args)
      if loaded?
        Kasket.clear_local if target.class.include?(WriteMixin)
      else
        target_class = proxy_reflection.options[:polymorphic] ? association_class : proxy_reflection.klass
        Kasket.clear_local if 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

9 entries across 9 versions & 1 rubygems

Version Path
kasket-1.0.4 lib/kasket/reload_association_mixin.rb
kasket-1.0.3 lib/kasket/reload_association_mixin.rb
kasket-1.0.3.beta2 lib/kasket/reload_association_mixin.rb
kasket-1.0.3.beta1 lib/kasket/reload_association_mixin.rb
kasket-1.0.2 lib/kasket/reload_association_mixin.rb
kasket-1.0.1 lib/kasket/reload_association_mixin.rb
kasket-1.0.0 lib/kasket/reload_association_mixin.rb
kasket-0.9.1 lib/kasket/reload_association_mixin.rb
kasket-0.9.0 lib/kasket/reload_association_mixin.rb