Class: Grendel::LinkedDocumentManager

Inherits:
Object
  • Object
show all
Defined in:
lib/grendel/linked_document_manager.rb

Instance Method Summary collapse

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

#listObject

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