Sha256: 7f5c46bc1e8e857c3b487aec408724e70540cdf7a69669411a3eef98de9bf867

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

module Clowne
  module Adapters # :nodoc: all
    class ActiveRecord
      module Associations
        class HasOne < Base
          def call(record)
            child = association
            return record unless child
            warn '[Clowne] Has one association does not support scopes' unless scope.nil?

            child_clone = clone_one(child)
            child_clone[:"#{reflection.foreign_key}"] = nil
            record.__send__(:"#{association_name}=", child_clone)

            record
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clowne-0.1.0.pre1 lib/clowne/adapters/active_record/associations/has_one.rb