Class: HorizonClient::Resource
- Inherits:
-
Object
- Object
- HorizonClient::Resource
- Defined in:
- lib/horizon_client/resource.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #collection ⇒ Object
- #entity ⇒ Object
- #error ⇒ Object
- #group ⇒ Object
-
#initialize(xml) ⇒ Resource
constructor
A new instance of Resource.
- #result ⇒ Object
Constructor Details
#initialize(xml) ⇒ Resource
Returns a new instance of Resource.
6 7 8 9 |
# File 'lib/horizon_client/resource.rb', line 6 def initialize(xml) @document = Ox.parse(xml) @xml = xml end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
3 4 5 |
# File 'lib/horizon_client/resource.rb', line 3 def document @document end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
4 5 6 |
# File 'lib/horizon_client/resource.rb', line 4 def xml @xml end |
Instance Method Details
#collection ⇒ Object
21 22 23 24 |
# File 'lib/horizon_client/resource.rb', line 21 def collection node = @document.resource.collection @collection ||= Collection.new(node) end |
#entity ⇒ Object
11 12 13 14 |
# File 'lib/horizon_client/resource.rb', line 11 def entity node = @document.resource.entity Entity.new(node) end |
#error ⇒ Object
31 32 33 34 35 |
# File 'lib/horizon_client/resource.rb', line 31 def error if document.respond_to?('error') document.error..text end end |