class Imperium::AgentListServicesResponse

AgentListServiceResponse is a wrapper for the raw HTTP::Message response

from the API

@note This class doesn't really make sense to be instantiated outside of

{Agent#list_services}

We've included Enumerable and implemented each so it can be treated as an array of {Service} objects.

Public Instance Methods

each(&block) click to toggle source
# File lib/imperium/agent_list_services_response.rb, line 16
def each(&block)
  services.each(&block)
end
services() click to toggle source

Build an array of {Service} objects from the response

@return [Array<Service>] This array will be empty when the response is not

a success
# File lib/imperium/agent_list_services_response.rb, line 24
def services
  @services ||= services_hash.values
end
services_hash() click to toggle source

Build a hash of {Service} object from the response

The keys are the service's id from the API response. @return [Hash<String => Service>]

# File lib/imperium/agent_list_services_response.rb, line 32
def services_hash
  @services_hash ||= (ok? ? coerced_body : {})
end