Class: ActiveShopifyGraphQL::Response::PageInfo
- Inherits:
-
Object
- Object
- ActiveShopifyGraphQL::Response::PageInfo
- Defined in:
- lib/active_shopify_graphql/response/page_info.rb
Overview
Holds pagination metadata returned from a Shopify GraphQL connection query. Provides methods for navigating between pages.
Instance Attribute Summary collapse
-
#end_cursor ⇒ Object
readonly
Returns the value of attribute end_cursor.
-
#start_cursor ⇒ Object
readonly
Returns the value of attribute start_cursor.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Check if this is an empty/null page info.
- #has_next_page? ⇒ Boolean
- #has_previous_page? ⇒ Boolean
-
#initialize(data = {}) ⇒ PageInfo
constructor
A new instance of PageInfo.
- #to_h ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ PageInfo
Returns a new instance of PageInfo.
10 11 12 13 14 15 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 10 def initialize(data = {}) @has_next_page = data["hasNextPage"] || false @has_previous_page = data["hasPreviousPage"] || false @start_cursor = data["startCursor"] @end_cursor = data["endCursor"] end |
Instance Attribute Details
#end_cursor ⇒ Object (readonly)
Returns the value of attribute end_cursor.
8 9 10 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 8 def end_cursor @end_cursor end |
#start_cursor ⇒ Object (readonly)
Returns the value of attribute start_cursor.
8 9 10 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 8 def start_cursor @start_cursor end |
Instance Method Details
#empty? ⇒ Boolean
Check if this is an empty/null page info
26 27 28 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 26 def empty? @start_cursor.nil? && @end_cursor.nil? end |
#has_next_page? ⇒ Boolean
17 18 19 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 17 def has_next_page? @has_next_page end |
#has_previous_page? ⇒ Boolean
21 22 23 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 21 def has_previous_page? @has_previous_page end |
#to_h ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/active_shopify_graphql/response/page_info.rb', line 30 def to_h { has_next_page: @has_next_page, has_previous_page: @has_previous_page, start_cursor: @start_cursor, end_cursor: @end_cursor } end |