Class: MongoModel::Associations::BelongsTo

Inherits:
MongoModel::Associations::Base::Definition show all
Defined in:
lib/mongomodel/concerns/associations/belongs_to.rb

Defined Under Namespace

Classes: Association

Instance Attribute Summary

Attributes inherited from MongoModel::Associations::Base::Definition

#name, #options, #owner

Instance Method Summary collapse

Methods inherited from MongoModel::Associations::Base::Definition

#define!, #for, #initialize, #klass, methods, #polymorphic?, properties, #scope, #scope_options, #singular_name

Constructor Details

This class inherits a constructor from MongoModel::Associations::Base::Definition

Instance Method Details

#collection?Boolean


12
13
14
# File 'lib/mongomodel/concerns/associations/belongs_to.rb', line 12

def collection?
  false
end

#foreign_keyObject


4
5
6
# File 'lib/mongomodel/concerns/associations/belongs_to.rb', line 4

def foreign_key
  @foreign_key ||= options[:foreign_key] || :"#{name}_id"
end

#type_keyObject


8
9
10
# File 'lib/mongomodel/concerns/associations/belongs_to.rb', line 8

def type_key
  @type_key ||= options[:type_key] || :"#{name}_type"
end