Class: Ape::Service

Inherits:
Object
  • Object
show all
Includes:
Util::InstanceMethods
Defined in:
lib/ape/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::InstanceMethods

#check_resource

Constructor Details

#initialize(opts = {}) ⇒ Service

uri = nil, authent = nil)



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ape/service.rb', line 12

def initialize(opts = {})                 #uri = nil, authent = nil)
  @authent = opts[:authent]
  @reporter = opts[:reporter]
  if opts[:uri]
    @uri = opts[:uri]
    resource = check_resource(@uri, 'Service document', Names::AppMediaType, @reporter)
    raise StandardError, "Service document not found at: #{@uri}" unless resource

    @service = REXML::Document.new(resource.body, { :raw => nil })
  end
end

Instance Attribute Details

#reporterObject

Returns the value of attribute reporter.



10
11
12
# File 'lib/ape/service.rb', line 10

def reporter
  @reporter
end

#serviceObject

Returns the value of attribute service.



10
11
12
# File 'lib/ape/service.rb', line 10

def service
  @service
end

Instance Method Details

#collections(uri = @uri) ⇒ Object



24
25
26
27
# File 'lib/ape/service.rb', line 24

def collections(uri = @uri)
  nodes = REXML::XPath.match(@service, '//app:collection', Names::XmlNamespaces)
  nodes.collect { |n| CollElement.new(n, uri) }
end