Sha256: e4c55a0cc7e6334adda922e3b04b9b4f12d56ca6414bb795bc3f2411cff87b62

Contents?: true

Size: 780 Bytes

Versions: 4

Compression:

Stored size: 780 Bytes

Contents

require 'syncano/active_record/association/base'

class Syncano
  module ActiveRecord
    module Association
      # Class for belongs to association
      class BelongsTo < Syncano::ActiveRecord::Association::Base
        attr_reader :associated_model, :foreign_key, :source_model

        # Constructor for belongs_to association
        # @param [Class] source_model
        # @param [Symbol] name
        def initialize(source_model, name)
          super
          self.foreign_key = associated_model.name.foreign_key
        end

        # Checks if association is belongs_to type
        # @return [TrueClass]
        def belongs_to?
          true
        end

        private

        attr_writer :associated_model, :foreign_key, :source_model
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
syncano-3.1.4 lib/syncano/active_record/association/belongs_to.rb
syncano-3.1.3 lib/syncano/active_record/association/belongs_to.rb
syncano-3.1.2 lib/syncano/active_record/association/belongs_to.rb
syncano-3.1.1 lib/syncano/active_record/association/belongs_to.rb