Sha256: f6f381e03481fe43fccc1c875c1c7d7b99ceface39a68c0bb8cff50e59c143c9

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

require 'syncano/model/scope_builder'

module Syncano
  module Model
    # Module with associations functionality for Syncano::ActiveRecord
    module Association
      # Base class for all associations
      class Base
        # Constructor for association
        # @param [Class] source_model
        # @param [Symbol] name
        def initialize(source_model, name, options = {})
          self.source_model = source_model
          self.associated_model = name.to_s.classify.constantize
          self.foreign_key = options[:foreign_key] || source_model.name.foreign_key
        end

        # Checks if association is belongs_to type
        # @return [FalseClass]
        def belongs_to?
          false
        end

        # Checks if association is has_one type
        # @return [FalseClass]
        def has_one?
          false
        end

        # Checks if association is has_many type
        # @return [FalseClass]
        def has_many?
          false
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
syncano-4.0.0.alpha1 lib/syncano/model/associations/base.rb
syncano-4.0.0.alpha lib/syncano/model/associations/base.rb
syncano-4.0.0.pre lib/syncano/model/associations/base.rb