Class: FluvPay::Resources::PageList
- Inherits:
-
Object
- Object
- FluvPay::Resources::PageList
- Includes:
- Enumerable
- Defined in:
- lib/fluvpay/resources/list_objects.rb
Overview
Página baseada em page/per_page (usada por charges.list e transactions.list).
Expõe #data (os itens) e os metadados page, per_page, total, has_next e has_prev, exatamente como o backend retorna. Também é iterável: page.each { |item| … }.
Instance Attribute Summary collapse
-
#data ⇒ Array<Hash>
readonly
Itens da página.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#has_next? ⇒ Boolean
True se existe próxima página.
-
#has_prev? ⇒ Boolean
True se existe página anterior.
-
#initialize(payload) ⇒ PageList
constructor
A new instance of PageList.
Constructor Details
#initialize(payload) ⇒ PageList
Returns a new instance of PageList.
17 18 19 20 21 22 23 24 25 |
# File 'lib/fluvpay/resources/list_objects.rb', line 17 def initialize(payload) payload ||= {} @data = payload["data"] || [] @page = payload["page"] @per_page = payload["per_page"] @total = payload["total"] @has_next = payload["has_next"] @has_prev = payload["has_prev"] end |
Instance Attribute Details
#data ⇒ Array<Hash> (readonly)
Returns itens da página.
14 15 16 |
# File 'lib/fluvpay/resources/list_objects.rb', line 14 def data @data end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
15 16 17 |
# File 'lib/fluvpay/resources/list_objects.rb', line 15 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
15 16 17 |
# File 'lib/fluvpay/resources/list_objects.rb', line 15 def per_page @per_page end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
15 16 17 |
# File 'lib/fluvpay/resources/list_objects.rb', line 15 def total @total end |
Instance Method Details
#each(&block) ⇒ Object
37 38 39 |
# File 'lib/fluvpay/resources/list_objects.rb', line 37 def each(&block) @data.each(&block) end |
#has_next? ⇒ Boolean
Returns true se existe próxima página.
28 29 30 |
# File 'lib/fluvpay/resources/list_objects.rb', line 28 def has_next? @has_next ? true : false end |
#has_prev? ⇒ Boolean
Returns true se existe página anterior.
33 34 35 |
# File 'lib/fluvpay/resources/list_objects.rb', line 33 def has_prev? @has_prev ? true : false end |