Class: Vorpal::Config::HasManyConfig
- Inherits:
-
Object
- Object
- Vorpal::Config::HasManyConfig
- Includes:
- RemoteEndConfig, Util::HashInitialization
- Defined in:
- lib/vorpal/config/has_many_config.rb
Overview
Object association terminology:
-
All object associations are uni-directional
-
The end that holds the association is the ‘Owner’ and the end that is referred to is the ‘Associate’ or ‘Associates’
Relational association terminology:
-
Local end: has FK
-
Remote end: has no FK
Instance Attribute Summary collapse
-
#associated_class ⇒ Object
readonly
Returns the value of attribute associated_class.
-
#association_config ⇒ Object
Returns the value of attribute association_config.
-
#fk ⇒ Object
readonly
Returns the value of attribute fk.
-
#fk_type ⇒ Object
readonly
Returns the value of attribute fk_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owned ⇒ Object
readonly
Returns the value of attribute owned.
-
#unique_key_name ⇒ Object
readonly
Returns the value of attribute unique_key_name.
Instance Method Summary collapse
Methods included from RemoteEndConfig
#associated_class_config, #foreign_key_info, #get_unique_key_value, #set_class_config, #set_foreign_key
Methods included from Util::HashInitialization
Instance Attribute Details
#associated_class ⇒ Object (readonly)
Returns the value of attribute associated_class.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def associated_class @associated_class end |
#association_config ⇒ Object
Returns the value of attribute association_config.
20 21 22 |
# File 'lib/vorpal/config/has_many_config.rb', line 20 def association_config @association_config end |
#fk ⇒ Object (readonly)
Returns the value of attribute fk.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def fk @fk end |
#fk_type ⇒ Object (readonly)
Returns the value of attribute fk_type.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def fk_type @fk_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def name @name end |
#owned ⇒ Object (readonly)
Returns the value of attribute owned.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def owned @owned end |
#unique_key_name ⇒ Object (readonly)
Returns the value of attribute unique_key_name.
19 20 21 |
# File 'lib/vorpal/config/has_many_config.rb', line 19 def unique_key_name @unique_key_name end |
Instance Method Details
#associate(owner, associates) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/vorpal/config/has_many_config.rb', line 26 def associate(owner, associates) if get_associated(owner).nil? owner.send("#{name}=", []) end get_associated(owner) << associates end |
#get_associated(owner) ⇒ Object
22 23 24 |
# File 'lib/vorpal/config/has_many_config.rb', line 22 def get_associated(owner) owner.send(name) end |
#pretty_name ⇒ Object
33 34 35 |
# File 'lib/vorpal/config/has_many_config.rb', line 33 def pretty_name "#{@class_config.domain_class.name} has_many :#{name}" end |