Module: NetboxClientRuby::Communication
- Included in:
- Entities, Entity, Secrets::RSAKeyPair, Secrets::SessionKey
- Defined in:
- lib/netbox_client_ruby/communication.rb
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
14 15 16 |
# File 'lib/netbox_client_ruby/communication.rb', line 14 def connection NetboxClientRuby::Connection.new end |
#hash_to_object(hash) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/netbox_client_ruby/communication.rb', line 18 def hash_to_object(hash) objectified_class = Class.new objectified_instance = objectified_class.new hash.each do |k, v| variable_name = sanitize_variable_name(k) variable_name = "_#{variable_name}" if objectified_instance.methods.map(&:to_s).include?(variable_name) objectified_instance.instance_variable_set(:"@#{variable_name}", v) objectified_class.send(:define_method, variable_name, proc { instance_variable_get(:"@#{variable_name}") }) end objectified_instance end |
#response(response) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/netbox_client_ruby/communication.rb', line 5 def response(response) return nil if response.status == 304 return {} if response.status == 204 raise_on_http_error response read response end |