Sha256: 3fd2c312f5dc18e564bd2eb168320eea61e9de6339ca2e4594d6b4ad4bfd9f94

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

module HorizonClient
  class Resource
    attr_reader :document
    attr_reader :xml

    def initialize(xml)
      @document = Ox.parse(xml)
      @xml = 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

2 entries across 2 versions & 1 rubygems

Version Path
horizon_client-0.2.7 lib/horizon_client/resource.rb
horizon_client-0.2.6 lib/horizon_client/resource.rb