Class: Isomorfeus::Puppetmaster::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/puppetmaster/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_hash = {}) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/isomorfeus/puppetmaster/response.rb', line 6

def initialize(response_hash = {})
  @response_hash = response_hash ? response_hash : {}
  @request = Isomorfeus::Puppetmaster::Request.new(@response_hash['request'])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/isomorfeus/puppetmaster/response.rb', line 11

def method_missing(name, *args)
  if %i[headers ok remote_address security_details status status_text text url].include?(name)
    @response_hash[name.to_s]
  elsif :ok? == name
    @response_hash['ok']
  else
    super(name, *args)
  end
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



4
5
6
# File 'lib/isomorfeus/puppetmaster/response.rb', line 4

def request
  @request
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/isomorfeus/puppetmaster/response.rb', line 21

def ok?
  @response_hash[:ok]
end