class Polyseerio::Client

The Polyseer.io client.

Constants

INITIALIZE_DEFAULTS

Attributes

agent[RW]
agent_class[RW]
cid[RW]
instance[RW]
request[RW]

Public Class Methods

new(cid, options = {}) click to toggle source
# File lib/client.rb, line 15
def initialize(cid, options = {})
  options = Helper.defaults(options, INITIALIZE_DEFAULTS)

  if options[:request].nil?
    raise ArgumentError, 'Cannot create an instance of Client without' \
      'passing a request instance.'
  end

  if options.key? :resources
    options[:resources].each(&Helper.attach_to_instance!(self))
  end

  @cid = cid
  @agent = nil
  @instance = nil
  @request = options[:request]
  @agent_class = options[:agent_class]
end

Public Instance Methods

start_agent(*args) click to toggle source

Start an agent using this client.

# File lib/client.rb, line 35
def start_agent(*args)
  raise 'Agent has already started.' unless @agent.nil?

  @agent = @agent_class.new(self)

  @agent.start(*args)
end