Module: Ripple::Associations::ClassMethods

Includes:
Translation
Defined in:
lib/ripple/associations.rb

Instance Method Summary collapse

Methods included from Translation

#i18n_scope

Instance Method Details

#associationsObject

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_correspondenceObject



97
98
99
# File 'lib/ripple/associations.rb', line 97

def configure_for_key_correspondence
  include Ripple::Associations::KeyDelegator
end

#embedded_associationsObject

Associations of embedded documents



71
72
73
# File 'lib/ripple/associations.rb', line 71

def embedded_associations
  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_associationsObject

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

Raises:

  • (ArgumentError)


92
93
94
95
# File 'lib/ripple/associations.rb', line 92

def many(name, options={})
  raise ArgumentError, t('many_key_association') if options[:using] === :key
  create_association(:many, name, options)
end

#one(name, options = {}) ⇒ Object

Creates a singular association



86
87
88
89
# File 'lib/ripple/associations.rb', line 86

def one(name, options={})
  configure_for_key_correspondence if options[:using] === :key
  create_association(:one, name, options)
end

#stored_key_associationsObject

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