Sha256: 503e9c4d270422ff2b44067c233862a93215f16d21da1992bb4aaa1540eb2593

Contents?: true

Size: 742 Bytes

Versions: 16

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

module Switchman
  class SchemaCache < ::ActiveRecord::ConnectionAdapters::SchemaCache
    delegate :connection, to: :pool
    attr_reader :pool

    SHARED_IVS = %i{@columns @columns_hash @primary_keys @data_sources @indexes}.freeze

    def initialize(pool)
      @pool = pool
      super(nil)
    end

    def copy_values(other_cache)
      SHARED_IVS.each do |iv|
        instance_variable_get(iv).replace(other_cache.instance_variable_get(iv))
      end
    end

    def copy_references(other_cache)
      # use the same cached values but still fall back to the correct pool
      SHARED_IVS.each do |iv|
        instance_variable_set(iv, other_cache.instance_variable_get(iv))
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
switchman-2.2.3 lib/switchman/schema_cache.rb
switchman-2.2.2 lib/switchman/schema_cache.rb
switchman-2.2.1 lib/switchman/schema_cache.rb
switchman-2.2.0 lib/switchman/schema_cache.rb
switchman-2.1.6 lib/switchman/schema_cache.rb
switchman-2.1.5 lib/switchman/schema_cache.rb
switchman-2.1.4 lib/switchman/schema_cache.rb
switchman-2.1.3 lib/switchman/schema_cache.rb
switchman-2.1.2 lib/switchman/schema_cache.rb
switchman-2.1.1 lib/switchman/schema_cache.rb
switchman-2.1.0 lib/switchman/schema_cache.rb
switchman-2.0.13 lib/switchman/schema_cache.rb
switchman-2.0.12 lib/switchman/schema_cache.rb
switchman-2.0.11 lib/switchman/schema_cache.rb
switchman-2.0.10 lib/switchman/schema_cache.rb
switchman-2.0.9 lib/switchman/schema_cache.rb