Method: ActiveCouch::Base.has_many
- Defined in:
- lib/active_couch/base.rb
.has_many(name, options = {}) ⇒ Object
Defines an array of objects which are ‘children’ of this class. The has_many function guesses the class of the child, based on the name of the association, but can be over-ridden by the :class key in the options hash.
Examples:
class Person < ActiveCouch::Base
has :name
end
class GrandPerson < ActiveCouch::Base
has_many :people # which will create an empty array which can contain
# Person objects
end
249 250 251 252 253 254 |
# File 'lib/active_couch/base.rb', line 249 def has_many(name, = {}) unless name.is_a?(String) || name.is_a?(Symbol) raise ArgumentError, "#{name} is neither a String nor a Symbol" end @associations[name] = HasManyAssociation.new(name, ) end |