Module: Shopkit::Traversal
- Included in:
- Client
- Defined in:
- lib/shopkit/traversal.rb
Instance Method Summary collapse
-
#traversal(options) ⇒ Object
遍历所有页面.
Instance Method Details
#traversal(options) ⇒ Object
遍历所有页面
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/shopkit/traversal.rb', line 4 def traversal() # 遍历所有页面 [:page] ||= 1 [:per_page] ||= per_page [:per_page] = 100 if auto_traversal list = yield() || [] if auto_traversal and !list.empty? [:page] += 1 list += traversal() do yield() end end list end |