Class: Stannum::Associations::Many
- Parent Namespace
- Stannum::Associations
- Inherited Classes
- Stannum::Association
>
Object
- Defined In
- lib/stannum/associations/many.rb
Table Of Contents
Overview
Data object representing a plural association.
Back To Top
Defined Under Namespace
- Classes
- Proxy
Back To Top
Constructor
#initialize(name:, options:, type:) => Association
- Inherited From
- Stannum::Association
Parameters
- name (String, Symbol) — The name of the association. Converted to a
String.
- options (Hash, nil) — Options for the association. Converted to a
Hash with Symbol keys. Defaults to an empty Hash.
- type (Class, Module, String) — The type of the association. Can be a
Class, a Module, or the name of a class or module.
Returns
- (Association) — a new instance of Association
Back To Top
Instance Attributes
#name => String (readonly)
- Inherited From
- Stannum::Association
Returns
- (String) — the name of the association.
#options => Hash (readonly)
- Inherited From
- Stannum::Association
Returns
- (Hash) — the association options.
#type => String (readonly)
- Inherited From
- Stannum::Association
Returns
- (String) — the name of the association type Class or Module.
Back To Top
Instance Methods
#add_value(entity, value, update_inverse: true) => void
Adds the given value to the association for the entity.
Parameters
- entity (Stannum::Entity) — the entity to update.
- value (Object) — the new value for the association.
- update_inverse (Boolean) — if true, updates the inverse association
(if any). Defaults to false.
Returns
#clear_value(entity, update_inverse: true) => void
Removes the value of the association for the entity.
Parameters
Returns
#entity_class_name => String, nil
- Inherited From
- Stannum::Association
Returns
- (String, nil) — the name of the original entity class.
#foreign_key? => true, false
- Inherited From
- Stannum::Association
Returns
- (true, false) — true if the association has defines a foreign key;
otherwise false.
#foreign_key_name => String?
- Inherited From
- Stannum::Association
Returns
- (String?) — the name of the foreign key, if any.
- Inherited From
- Stannum::Association
Returns
#get_value(entity) => Object
Retrieves the value of the association for the entity.
Parameters
Returns
- (Object) — the value of the association.
#inverse? => Boolean
- Inherited From
- Stannum::Association
Returns
- (Boolean) — true if the association has an inverse association;
otherwise false.
#inverse_name => String
- Inherited From
- Stannum::Association
Returns
- (String) — the name of the inverse association, if any.
#many? => true
Returns
- (true) — true if the association is a plural association; otherwise
false.
#one? => false
- Inherited From
- Stannum::Association
Returns
- (false) — true if the association is a singular association;
otherwise false.
#reader_name => Symbol
- Inherited From
- Stannum::Association
Returns
- (Symbol) — the name of the reader method for the association.
#remove_value(entity, value, update_inverse: true) => void
Removes the given value from the association for the entity.
Parameters
- entity (Stannum::Entity) — the entity to update.
- value (Stannum::Entity) — the association value to remove.
- update_inverse (Boolean) — if true, updates the inverse association
(if any). Defaults to false.
Returns
Returns
Raises
- (InverseAssociationError)
#resolved_type => Module
- Inherited From
- Stannum::Association
Returns
- (Module) — the type of the association.
#set_value(entity, value, update_inverse: true) => void
Replaces the association for the entity with the given value.
Parameters
- entity (Stannum::Entity) — the entity to update.
- value (Object) — the new value for the association.
- update_inverse (Boolean) — if true, updates the inverse association
(if any). Defaults to false.
Returns
#writer_name => Symbol
- Inherited From
- Stannum::Association
Returns
- (Symbol) — the name of the writer method for the association.
Back To Top
Back to
Documentation |
Reference
|
Stannum
|
Stannum::Associations