diff --git a/app/models/collection.rb b/app/models/collection.rb index d5a481f21750cc780eec290c1f1ec3319047972b..07142afcd87c46d65cd3d220cdeb9b3c498f268a 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -10,6 +10,31 @@ class Collection super(params.merge(defaults)) end + ## + # Add +learning_object+ to collection + # + # After adding some learning object to collection, you must use CollectionRepository to persist + # the changes. + # + # Example: + # @test_collection = Collection.new(name: 'test', description: 'test', owner: current_user) + # @test_collection.add @learning_object + # + # @test_collection.learning_objects # [@learning_object] + # collection_repository.save @test_collection + def add(learning_object) + learning_objects.append learning_object + end + + ## + # Remove +learning_object+ from collection + # + # After remove some learning object to collection, you must use CollectionRepository to persist + # the changes. + def remove(learning_object) + learning_objects.delete learning_object + end + private def defaults