Module: Prtg::Query::InstanceMethods

Defined in:
lib/prtg/query.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/prtg/query.rb', line 49

def method_missing(*args, &block)
  if args.first.to_s.start_with? "filter"
    add_filter(*args)
  else
    execute.send(*args, &block)
  end
end

Instance Method Details

#add_filter(name, value) ⇒ Object



44
45
46
47
# File 'lib/prtg/query.rb', line 44

def add_filter(name, value)
  @query[name.to_sym] = value
  self
end

#executeObject



35
36
37
38
39
40
41
42
# File 'lib/prtg/query.rb', line 35

def execute
  url_params = Utils.url_params(@query)

  parse_response @host.get(
    "#{ api_url }?#{ url_params }",
    { "Accept-Encoding" => "*"}
  )
end

#initialize(host, auth_params = {}) ⇒ Object



29
30
31
32
33
# File 'lib/prtg/query.rb', line 29

def initialize(host, auth_params={})
  @host = host
  @query = {}.merge(auth_params)
  @query[:output]  = :xml
end