Sha256: ac621fcd450bc661b18671624dd701f15691dc1e3a9e35e0ec9485b4c0b7cef6

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

module Grendel
  class LinkedDocument < Document
    attr_accessor :linked_user, :owner
    
    # create a new linked document
    # user - linked user
    # params:
    # :name => document name
    # :uri => linked document uri
    # :owner => {
    #   :id => owner id
    #   :uri => owner uri
    # }
    def initialize(linked_user, params)
      params.symbolize_keys!
      @owner = User.new(linked_user.client, params[:owner])
      super(@owner, params)
      @linked_user = linked_user
      @name = params[:name]
      @uri = params[:uri] ? 
        URI.parse(params[:uri]).path :
        ["/linked-documents", @owner.id, name].join("/")
    end
    
    # delete this linked document
    def delete
      @linked_user.delete(@uri)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grendel-ruby-0.1.1 lib/grendel/linked_document.rb