Class: Hawkular::Inventory::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/hawkular/inventory/entities.rb

Overview

Definition of a Relationship between two entities in Inventory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Relationship

Returns a new instance of Relationship



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/hawkular/inventory/entities.rb', line 138

def initialize(hash = {})
  if hash.empty?
    @properties = {}
    return
  end

  @source_id = hash['source']
  @target_id = hash['target']
  @properties = hash['properties']
  @name = hash['name']
  @id = hash['id']
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id



136
137
138
# File 'lib/hawkular/inventory/entities.rb', line 136

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name



135
136
137
# File 'lib/hawkular/inventory/entities.rb', line 135

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties



134
135
136
# File 'lib/hawkular/inventory/entities.rb', line 134

def properties
  @properties
end

#source_idObject

Returns the value of attribute source_id



132
133
134
# File 'lib/hawkular/inventory/entities.rb', line 132

def source_id
  @source_id
end

#target_idObject (readonly)

Returns the value of attribute target_id



133
134
135
# File 'lib/hawkular/inventory/entities.rb', line 133

def target_id
  @target_id
end

Instance Method Details

#to_hObject



151
152
153
154
155
156
157
158
159
# File 'lib/hawkular/inventory/entities.rb', line 151

def to_h
  hash = {}
  hash['source'] = @source_id
  hash['target'] = @target_id
  hash['properties'] = @properties
  hash['name'] = @name
  hash['id'] = @id
  hash
end