Class: Grendel::LinkedDocumentManager
- Inherits:
-
Object
- Object
- Grendel::LinkedDocumentManager
- Defined in:
- lib/grendel/linked_document_manager.rb
Instance Method Summary collapse
-
#delete(owner_id, name) ⇒ Object
delete the linked document.
-
#find(owner_id, name) ⇒ Object
retreive a linked document.
-
#initialize(user) ⇒ LinkedDocumentManager
constructor
A new instance of LinkedDocumentManager.
-
#list ⇒ Object
list this user’s linked documents.
Constructor Details
#initialize(user) ⇒ LinkedDocumentManager
Returns a new instance of LinkedDocumentManager.
3 4 5 6 |
# File 'lib/grendel/linked_document_manager.rb', line 3 def initialize(user) @user = user @base_uri = "/linked-documents" end |
Instance Method Details
#delete(owner_id, name) ⇒ Object
delete the linked document
27 28 29 |
# File 'lib/grendel/linked_document_manager.rb', line 27 def delete(owner_id, name) @user.delete([@base_uri, owner_id, name].join("/")) end |
#find(owner_id, name) ⇒ Object
retreive a linked document
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/grendel/linked_document_manager.rb', line 15 def find(owner_id, name) response = @user.get([@base_uri, owner_id, name].join("/")) params = { :name => name, :data => response.body, :content_type => response.headers['content-type'].first, :owner => { :id => owner_id } } LinkedDocument.new(@user, params) end |
#list ⇒ Object
list this user’s linked documents. Returns an array of LinkedDocument objects
9 10 11 12 |
# File 'lib/grendel/linked_document_manager.rb', line 9 def list response = @user.get(@base_uri) response["linked-documents"].map {|ld| LinkedDocument.new(@user, ld) } end |