Class: HorizonClient::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/horizon_client/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Entity



5
6
7
# File 'lib/horizon_client/entity.rb', line 5

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



3
4
5
# File 'lib/horizon_client/entity.rb', line 3

def node
  @node
end

Instance Method Details

#[](name) ⇒ Object



9
10
11
12
# File 'lib/horizon_client/entity.rb', line 9

def [](name)
  attr_node = node.locate(name).first
  get_value attr_node
end

#[]=(name, value) ⇒ Object



14
15
16
17
# File 'lib/horizon_client/entity.rb', line 14

def []=(name, value)
  elem = find_or_build_attribute(name.split('/'), node)
  elem.replace_text(value)
end

#get_collection(name) ⇒ Object



19
20
21
22
# File 'lib/horizon_client/entity.rb', line 19

def get_collection(name)
  collection_node = find_or_build_attribute(name.split('/'), node)
  Collection.new(collection_node)
end