Sha256: b4ad8facc02d0ba602215d3ff024504c93f78b125ff8c82d076ccc2a3d6776d0

Contents?: true

Size: 868 Bytes

Versions: 5

Compression:

Stored size: 868 Bytes

Contents

module Grendel
  class LinkedDocumentManager
    def initialize(user)
      @user = user
      @base_uri = "/linked-documents"
    end
    
    # list this user's linked documents. Returns an array of LinkedDocument objects
    def list
      response = @user.get(@base_uri)
      response["linked-documents"].map {|ld| LinkedDocument.new(@user, ld) }
    end
    
    # retreive a linked document
    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
    
    # delete the linked document
    def delete(owner_id, name)
      @user.delete([@base_uri, owner_id, name].join("/"))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grendel-ruby-0.1.5 lib/grendel/linked_document_manager.rb
grendel-ruby-0.1.4 lib/grendel/linked_document_manager.rb
grendel-ruby-0.1.3 lib/grendel/linked_document_manager.rb
grendel-ruby-0.1.2 lib/grendel/linked_document_manager.rb
grendel-ruby-0.1.1 lib/grendel/linked_document_manager.rb