Class: Clearbit::Discovery::PagedResult
- Inherits:
-
Delegator
- Object
- Delegator
- Clearbit::Discovery::PagedResult
- Defined in:
- lib/clearbit/discovery.rb
Instance Method Summary collapse
- #__getobj__ ⇒ Object
- #__setobj__(obj) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(params, response) ⇒ PagedResult
constructor
A new instance of PagedResult.
- #map(&block) ⇒ Object
Constructor Details
#initialize(params, response) ⇒ PagedResult
Returns a new instance of PagedResult.
9 10 11 12 |
# File 'lib/clearbit/discovery.rb', line 9 def initialize(params, response) @params = params super Mash.new(response) end |
Instance Method Details
#__getobj__ ⇒ Object
14 15 16 |
# File 'lib/clearbit/discovery.rb', line 14 def __getobj__ @response end |
#__setobj__(obj) ⇒ Object
18 19 20 |
# File 'lib/clearbit/discovery.rb', line 18 def __setobj__(obj) @response = obj end |
#each(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/clearbit/discovery.rb', line 22 def each(&block) return enum_for(:each) unless block_given? results.each do |result| yield result end if results.any? search = Discovery.search( @params.merge(page: page + 1) ) search.each(&block) end end |
#map(&block) ⇒ Object
37 38 39 |
# File 'lib/clearbit/discovery.rb', line 37 def map(&block) each.map(&block) end |