Sha256: 42c056e9b218d136315971ccf63a6a5c8c890e67da9b35163d41262548681f61

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module HorizonClient
  class Resource
    attr_reader :document

    def initialize(xml)
      @document = Ox.parse(xml)
    end

    def entity
      node = @document.resource.entity
      Entity.new(node)
    end

    def result
      node = @document.result
      Entity.new(node)
    end

    def collection
      node = @document.resource.collection
      @collection ||= Collection.new(node)
    end

    def group
      node = @document.resource.group
      @group ||= Group.new(node)
    end

    def error
      if document.respond_to?('error')
        document.error.message.text
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
horizon_client-0.2.5 lib/horizon_client/resource.rb