require 'syncano/model/associations/base' module Syncano module Model module Association # Class for belongs to association class BelongsTo < Syncano::Model::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, options = {}) super self.foreign_key = options[: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