class NoSE::Fields::ForeignKeyField
Field
holding a foreign key to another entity
Attributes
entity[R]
relationship[R]
reverse[RW]
Public Class Methods
new(name, entity, **options)
click to toggle source
Calls superclass method
NoSE::Fields::IDField::new
# File lib/nose/model/fields.rb, line 289 def initialize(name, entity, **options) @relationship = options.delete(:relationship) || :one super(name, **options) @primary_key = false @entity = entity end
Public Instance Methods
cardinality()
click to toggle source
The number of entities associated with the foreign key, or a manually set cardinality @return [Integer]
Calls superclass method
NoSE::Fields::Field#cardinality
# File lib/nose/model/fields.rb, line 299 def cardinality @entity.count || super end