Class: Hawkular::Inventory::BaseEntity
- Inherits:
-
Object
- Object
- Hawkular::Inventory::BaseEntity
- Defined in:
- lib/hawkular/inventory/entities.rb
Overview
A Basic inventory entity with id, name, path and optional properties
Direct Known Subclasses
Metric, MetricType, OperationDefinition, Resource, ResourceType
Instance Attribute Summary collapse
-
#env ⇒ String
readonly
Name of the environment for this entity.
-
#feed ⇒ String
readonly
Feed this entity belongs to (or nil in case of a feedless entity).
-
#id ⇒ String
readonly
Id of the entity.
-
#name ⇒ String
readonly
Name of the entity.
-
#path ⇒ String
readonly
Full path of the entity.
-
#properties ⇒ String
readonly
Properties of this entity.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(hash) ⇒ BaseEntity
constructor
A new instance of BaseEntity.
-
#to_h ⇒ Hash<String,Object>
Returns a hash representation of the resource type.
Constructor Details
#initialize(hash) ⇒ BaseEntity
Returns a new instance of BaseEntity
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hawkular/inventory/entities.rb', line 18 def initialize(hash) @id = hash['id'] @path = hash['path'] @name = hash['name'] || @id @properties = hash['properties'] || {} @_hash = hash.dup return if @path.nil? tmp = @path.split('/') tmp.each do |pair| (key, val) = pair.split(';') case key when 'f' @feed = val when 'e' @env = val end end end |
Instance Attribute Details
#env ⇒ String (readonly)
Returns Name of the environment for this entity
14 15 16 |
# File 'lib/hawkular/inventory/entities.rb', line 14 def env @env end |
#feed ⇒ String (readonly)
Returns Feed this entity belongs to (or nil in case of a feedless entity)
12 13 14 |
# File 'lib/hawkular/inventory/entities.rb', line 12 def feed @feed end |
#id ⇒ String (readonly)
Returns Id of the entity
10 11 12 |
# File 'lib/hawkular/inventory/entities.rb', line 10 def id @id end |
#name ⇒ String (readonly)
Returns Name of the entity
8 9 10 |
# File 'lib/hawkular/inventory/entities.rb', line 8 def name @name end |
#path ⇒ String (readonly)
Returns Full path of the entity
6 7 8 |
# File 'lib/hawkular/inventory/entities.rb', line 6 def path @path end |
#properties ⇒ String (readonly)
Returns Properties of this entity
16 17 18 |
# File 'lib/hawkular/inventory/entities.rb', line 16 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/hawkular/inventory/entities.rb', line 39 def ==(other) self.equal?(other) || other.class == self.class && other.id == @id end |
#to_h ⇒ Hash<String,Object>
Returns a hash representation of the resource type
45 46 47 |
# File 'lib/hawkular/inventory/entities.rb', line 45 def to_h @_hash.dup end |