Module: HbExporter::Helper::RecursivelyFetch

Includes:
HTTParty
Included in:
Board, User
Defined in:
lib/hb_exporter/helper/recursively_fetch.rb

Instance Method Summary collapse

Instance Method Details

#recursively_fetch(path, ret, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hb_exporter/helper/recursively_fetch.rb', line 10

def recursively_fetch(path, ret, &block)
  opts = {
    query: {
      limit: 100,
      max: @max,
      wtfl: 1
    },

    headers: {
      'X-Requested-With' => 'XMLHttpRequest'
    }
  }
  res = ::HbExporter::Helper::RecursivelyFetch.get(path, opts)
  block.call(res).tap do |data|
    if data
      return recursively_fetch(path, ret + data, &block)
    else
      return ret
    end
  end
end