Class: Ganeti::GanetiObject
- Inherits:
-
Object
- Object
- Ganeti::GanetiObject
- Defined in:
- lib/ganeti_client/ganeti_object.rb
Instance Attribute Summary collapse
-
#json_object ⇒ Object
Returns the value of attribute json_object.
Instance Method Summary collapse
-
#initialize(json = {}) ⇒ GanetiObject
constructor
A new instance of GanetiObject.
- #to_json ⇒ Object
Constructor Details
#initialize(json = {}) ⇒ GanetiObject
Returns a new instance of GanetiObject.
6 7 8 9 10 11 12 13 |
# File 'lib/ganeti_client/ganeti_object.rb', line 6 def initialize(json = {}) new_json = {} json.each { |key, value| new_json[key.gsub('.', '_')] = value } self.json_object = new_json new_json.each { |attr_name, attr_value| self.class.send(:define_method, attr_name.to_sym){ return attr_value } } end |
Instance Attribute Details
#json_object ⇒ Object
Returns the value of attribute json_object.
4 5 6 |
# File 'lib/ganeti_client/ganeti_object.rb', line 4 def json_object @json_object end |
Instance Method Details
#to_json ⇒ Object
15 16 17 |
# File 'lib/ganeti_client/ganeti_object.rb', line 15 def to_json return self.json_object end |