Class: Factual::Multi

Inherits:
Object
  • Object
show all
Defined in:
lib/factual/multi.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, queries) ⇒ Multi

Returns a new instance of Multi.



5
6
7
8
9
10
11
12
13
# File 'lib/factual/multi.rb', line 5

def initialize(api, queries)
  @api = api
  @queries = queries

  @action = nil
  @path = '/multi'

  @responses = {}
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/factual/multi.rb', line 3

def action
  @action
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/factual/multi.rb', line 3

def path
  @path
end

Instance Method Details

#bodyObject



25
26
27
28
29
30
31
32
# File 'lib/factual/multi.rb', line 25

def body
  query_urls = {}
  @queries.each do |name, query|
    query_urls[name] = query.full_path
  end

  "queries=#{ CGI.escape(query_urls.to_json) }"
end

#sendObject



15
16
17
18
19
20
21
22
23
# File 'lib/factual/multi.rb', line 15

def send
  res = @api.post(self)
  @queries.each do |name, query|
    query.populate(res[name.to_s])
    @responses[name] = query
  end

  @responses
end