Module: Dynamoid::Associations::Association
- Included in:
- HasOne, ManyAssociation, SingleAssociation
- Defined in:
- lib/dynamoid/associations/association.rb
Instance Attribute Summary collapse
- #loaded ⇒ Object
-
#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
12 13 14 |
# File 'lib/dynamoid/associations/association.rb', line 12 def loaded @loaded end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/dynamoid/associations/association.rb', line 10 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/dynamoid/associations/association.rb', line 10 def @options end |
#source ⇒ Object
Returns the value of attribute source.
10 11 12 |
# File 'lib/dynamoid/associations/association.rb', line 10 def source @source end |
Instance Method Details
#declaration_field_name ⇒ Object
59 60 61 |
# File 'lib/dynamoid/associations/association.rb', line 59 def declaration_field_name "#{name}_ids" end |
#declaration_field_type ⇒ Object
64 65 66 |
# File 'lib/dynamoid/associations/association.rb', line 64 def declaration_field_type :set end |
#disassociate_source ⇒ Object
69 70 71 72 73 |
# File 'lib/dynamoid/associations/association.rb', line 69 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
40 |
# File 'lib/dynamoid/associations/association.rb', line 40 def find_target; end |
#initialize(source, name, options) ⇒ Dynamoid::Association
Create a new association.
27 28 29 30 31 32 |
# File 'lib/dynamoid/associations/association.rb', line 27 def initialize(source, name, ) @name = name @options = @source = source @loaded = false end |
#loaded? ⇒ Boolean
35 36 37 |
# File 'lib/dynamoid/associations/association.rb', line 35 def loaded? @loaded end |
#reset ⇒ Object
53 54 55 56 |
# File 'lib/dynamoid/associations/association.rb', line 53 def reset @target = nil @loaded = false end |
#target ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/dynamoid/associations/association.rb', line 43 def target unless loaded? @target = find_target @loaded = true end @target end |