Sha256: 717a9aac3c417eca38a33242ace1f443706577b739ea16b04e8a4ecbf708336c

Contents?: true

Size: 798 Bytes

Versions: 16

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

module IdentityCache
  class ExpiryHook
    def initialize(cached_association)
      @cached_association = cached_association
    end

    def install
      cached_association.validate
      entry = [parent_class, only_on_foreign_key_change?]
      child_class.parent_expiration_entries[inverse_name] << entry
    end

    private

    attr_reader :cached_association

    def only_on_foreign_key_change?
      cached_association.embedded_by_reference? && !cached_association.reflection.has_scope?
    end

    def inverse_name
      cached_association.inverse_name
    end

    def parent_class
      cached_association.reflection.active_record
    end

    def child_class
      cached_association.reflection.klass
    end
  end

  private_constant :ExpiryHook
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
identity_cache-1.6.3 lib/identity_cache/expiry_hook.rb
identity_cache-1.6.2 lib/identity_cache/expiry_hook.rb
identity_cache-1.6.1 lib/identity_cache/expiry_hook.rb
identity_cache-1.6.0 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.6 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.5 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.4 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.3 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.2 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.1 lib/identity_cache/expiry_hook.rb
identity_cache-1.5.0 lib/identity_cache/expiry_hook.rb
identity_cache-1.4.1 lib/identity_cache/expiry_hook.rb
identity_cache-1.4.0 lib/identity_cache/expiry_hook.rb
identity_cache-1.3.1 lib/identity_cache/expiry_hook.rb
identity_cache-1.3.0 lib/identity_cache/expiry_hook.rb
identity_cache-1.2.0 lib/identity_cache/expiry_hook.rb