Class: Qmetrics::Caller

Inherits:
Object
  • Object
show all
Defined in:
lib/qmetrics/caller.rb

Direct Known Subclasses

Realtime, Stats

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queues:, api:) ⇒ Caller

Returns a new instance of Caller.



8
9
10
11
12
# File 'lib/qmetrics/caller.rb', line 8

def initialize(queues: , api: )
  @queues = queues
  @api = api
  clear_blocks
end

Class Attribute Details

.api_methodsObject (readonly)

Returns the value of attribute api_methods.



5
6
7
# File 'lib/qmetrics/caller.rb', line 5

def api_methods
  @api_methods
end

Class Method Details

.load_api_methods(file) ⇒ Object



27
28
29
# File 'lib/qmetrics/caller.rb', line 27

def self.load_api_methods(file)
  @api_methods ||= load_yml(file)
end

Instance Method Details

#api_methodsObject



31
32
33
# File 'lib/qmetrics/caller.rb', line 31

def api_methods
  self.class.api_methods
end

#get(*args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/qmetrics/caller.rb', line 14

def get(*args)
  clear_blocks
  args.each do |k|
    @blocks.push(api_methods[k.to_sym]) if call_exists?(k.to_sym)
  end
  execute
end

#to_sObject

url encoded ‘|’ to ‘%7C’



23
24
25
# File 'lib/qmetrics/caller.rb', line 23

def to_s
  "/jsonStatsApi.do?queues=#{@queues.join('%7C')}"
end