Sha256: 63cc7f3c88791ec27419897d1631848080cfb7e2cdb0d9fe972418b3864967d9

Contents?: true

Size: 998 Bytes

Versions: 2

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

require "clowne/adapters/active_record/associations/base"
require "clowne/adapters/active_record/associations/noop"
require "clowne/adapters/active_record/associations/belongs_to"
require "clowne/adapters/active_record/associations/has_one"
require "clowne/adapters/active_record/associations/has_many"
require "clowne/adapters/active_record/associations/has_and_belongs_to_many"

module Clowne
  module Adapters # :nodoc: all
    class ActiveRecord
      module Associations
        AR_2_CLONER = {
          belongs_to: BelongsTo,
          has_one: HasOne,
          has_many: HasMany,
          has_and_belongs_to_many: HABTM,
        }.freeze

        # Returns an association cloner class for reflection
        def self.cloner_for(reflection)
          if reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection)
            Noop
          else
            AR_2_CLONER.fetch(reflection.macro, Noop)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clowne-1.3.0 lib/clowne/adapters/active_record/associations.rb
clowne-1.2.0 lib/clowne/adapters/active_record/associations.rb