Sha256: 68f41cbf84a325aa9a7cea59f32e7f965f928bcf30f741b2a7840d8379da4e4d

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 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

1 entries across 1 versions & 1 rubygems

Version Path
clowne-1.1.0 lib/clowne/adapters/active_record/associations.rb