Sha256: 28fa738b4e2de4c9826375f60a2d63bf659dc3fd3d35944f1a6f0ce81d9e39b1

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

module Clowne
  module Adapters # :nodoc: all
    class ActiveRecord
      module Associations
        class BelongsTo < Base
          # rubocop: disable Metrics/MethodLength
          def call(record)
            child = association
            return record unless child

            unless declaration.scope.nil?
              warn(
                '[Clowne] Belongs to association does not support scopes ' \
                "(#{@association_name} for #{@source.class})"
              )
            end

            child_clone = clone_one(child)
            record.__send__(:"#{association_name}=", child_clone)
            record
          end
          # rubocop: enable Metrics/MethodLength
        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/belongs_to.rb