Module: Ripple::Associations::ClassMethods
- Includes:
- Translation
- Defined in:
- lib/ripple/associations.rb
Instance Method Summary collapse
-
#associations ⇒ Object
Associations defined on the document.
- #configure_for_key_correspondence ⇒ Object
-
#embedded_associations ⇒ Object
Associations of embedded documents.
- #inherited(subclass) ⇒ Object
-
#linked_associations ⇒ Object
Associations of linked documents.
-
#many(name, options = {}) ⇒ Object
Creates a plural association.
-
#one(name, options = {}) ⇒ Object
Creates a singular association.
-
#stored_key_associations ⇒ Object
Associations of stored_key documents.
Methods included from Translation
Instance Method Details
#associations ⇒ Object
Associations defined on the document
66 67 68 |
# File 'lib/ripple/associations.rb', line 66 def associations @associations ||= {}.with_indifferent_access end |
#configure_for_key_correspondence ⇒ Object
97 98 99 |
# File 'lib/ripple/associations.rb', line 97 def configure_for_key_correspondence include Ripple::Associations::KeyDelegator end |
#embedded_associations ⇒ Object
Associations of embedded documents
71 72 73 |
# File 'lib/ripple/associations.rb', line 71 def associations.values.select(&:embedded?) end |
#inherited(subclass) ⇒ Object
60 61 62 63 |
# File 'lib/ripple/associations.rb', line 60 def inherited(subclass) super subclass.associations.merge!(associations) end |
#linked_associations ⇒ Object
Associations of linked documents
76 77 78 |
# File 'lib/ripple/associations.rb', line 76 def linked_associations associations.values.select(&:linked?) end |
#many(name, options = {}) ⇒ Object
Creates a plural association
92 93 94 95 |
# File 'lib/ripple/associations.rb', line 92 def many(name, ={}) raise ArgumentError, t('many_key_association') if [:using] === :key create_association(:many, name, ) end |
#one(name, options = {}) ⇒ Object
Creates a singular association
86 87 88 89 |
# File 'lib/ripple/associations.rb', line 86 def one(name, ={}) configure_for_key_correspondence if [:using] === :key create_association(:one, name, ) end |
#stored_key_associations ⇒ Object
Associations of stored_key documents
81 82 83 |
# File 'lib/ripple/associations.rb', line 81 def stored_key_associations associations.values.select(&:stored_key?) end |