Method: Scribd::Collection#add
- Defined in:
- lib/scribd/collection.rb
#add(document, ignore_if_exists = true) ⇒ Scribd::Document
Adds a Document to this collection.
the document is already in the collection. the document already exists in the collection. See the online API documentation for more information.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/scribd/collection.rb', line 43 def add(document, ignore_if_exists=true) raise ArgumentError, "You can only add Scribd::Documents to collections" unless document.kind_of?(Scribd::Document) begin API.instance.send_request 'docs.addToCollection', :collection_id => collection_id, :doc_id => document.id, :session_key => owner.session_key rescue ResponseError => err raise unless ignore_if_exists raise if err.code.to_i != DOCUMENT_EXISTS_ERROR_CODE end return document end |