Module: Dynamoid::Associations::Association
- Included in:
- HasOne, ManyAssociation, SingleAssociation
- Defined in:
- lib/dynamoid/associations/association.rb
Instance Attribute Summary collapse
-
#loaded ⇒ Object
Returns the value of attribute loaded.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #declaration_field_name ⇒ Object
- #declaration_field_type ⇒ Object
- #disassociate_source ⇒ Object
- #find_target ⇒ Object
-
#initialize(source, name, options) ⇒ Dynamoid::Association
Create a new association.
- #loaded? ⇒ Boolean
- #reset ⇒ Object
- #target ⇒ Object
Instance Attribute Details
#loaded ⇒ Object
Returns the value of attribute loaded.
11 12 13 |
# File 'lib/dynamoid/associations/association.rb', line 11 def loaded @loaded end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/dynamoid/associations/association.rb', line 11 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/dynamoid/associations/association.rb', line 11 def @options end |
#source ⇒ Object
Returns the value of attribute source.
11 12 13 |
# File 'lib/dynamoid/associations/association.rb', line 11 def source @source end |
Instance Method Details
#declaration_field_name ⇒ Object
53 54 55 |
# File 'lib/dynamoid/associations/association.rb', line 53 def declaration_field_name "#{name}_ids" end |
#declaration_field_type ⇒ Object
57 58 59 |
# File 'lib/dynamoid/associations/association.rb', line 57 def declaration_field_type :set end |
#disassociate_source ⇒ Object
61 62 63 64 65 |
# File 'lib/dynamoid/associations/association.rb', line 61 def disassociate_source Array(target).each do |target_entry| target_entry.send(target_association).disassociate(source.hash_key) if target_entry && target_association end end |
#find_target ⇒ Object
37 |
# File 'lib/dynamoid/associations/association.rb', line 37 def find_target; end |
#initialize(source, name, options) ⇒ Dynamoid::Association
Create a new association.
26 27 28 29 30 31 |
# File 'lib/dynamoid/associations/association.rb', line 26 def initialize(source, name, ) @name = name @options = @source = source @loaded = false end |
#loaded? ⇒ Boolean
33 34 35 |
# File 'lib/dynamoid/associations/association.rb', line 33 def loaded? @loaded end |
#reset ⇒ Object
48 49 50 51 |
# File 'lib/dynamoid/associations/association.rb', line 48 def reset @target = nil @loaded = false end |
#target ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/dynamoid/associations/association.rb', line 39 def target unless loaded? @target = find_target @loaded = true end @target end |