Class: DDD::Associations::OneToManyCollection

Inherits:
ManyCollection show all
Defined in:
lib/ddd-associations/one_to_many_collection.rb

Instance Method Summary collapse

Methods inherited from ManyCollection

#initialize

Constructor Details

This class inherits a constructor from DDD::Associations::ManyCollection

Instance Method Details

#<<(another_one) ⇒ Object



4
5
6
7
8
9
# File 'lib/ddd-associations/one_to_many_collection.rb', line 4

def <<(another_one)
  unless many.include?(another_one)
    many << another_one
    another_one.send("#{collection_name}=", one)
  end
end

#delete(another_one) ⇒ Object



11
12
13
14
15
16
# File 'lib/ddd-associations/one_to_many_collection.rb', line 11

def delete(another_one)
  if many.include?(another_one)
    many.delete(another_one)
    another_one.send("#{collection_name}=", nil)
  end
end