Class: EPlat::Collection

Inherits:
ActiveResource::Collection
  • Object
show all
Defined in:
lib/e_plat/resource/collection.rb

Constant Summary collapse

SHOPIFY_GRAPHQL_PAGINATABLE_CLASSES =
%w(
	EPlat::Product
	EPlat::Product::Variant
	EPlat::Shopify::Product
	EPlat::Shopify::Product::Variant
)

Instance Method Summary collapse

Constructor Details

#initialize(parsed = {}) ⇒ Collection

Returns a new instance of Collection.



12
13
14
# File 'lib/e_plat/resource/collection.rb', line 12

def initialize(parsed = {})
	super parsed
end

Instance Method Details

#fetch_next_pageObject



36
37
38
39
# File 'lib/e_plat/resource/collection.rb', line 36

def fetch_next_page
	return unless pagination_available?
	fetch_page(@next)
end

#fetch_previous_pageObject



41
42
43
44
# File 'lib/e_plat/resource/collection.rb', line 41

def fetch_previous_page
	return unless pagination_available?
	fetch_page(@previous)
end

#next_page?Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/e_plat/resource/collection.rb', line 16

def next_page?
	return false unless pagination_available?
	@next.present?
end

#next_page_infoObject



26
27
28
29
# File 'lib/e_plat/resource/collection.rb', line 26

def next_page_info
	return unless pagination_available?
	extract_page_info(@next)
end

#paginates_via_graphql?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/e_plat/resource/collection.rb', line 46

def paginates_via_graphql?
	return unless SHOPIFY_GRAPHQL_PAGINATABLE_CLASSES.include? resource_class.to_s

	client.shopify? && client.api_version != "2024_01"
end

#previous_page?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/e_plat/resource/collection.rb', line 21

def previous_page?
	return false unless pagination_available?
	@previous.present?
end

#previous_page_infoObject



31
32
33
34
# File 'lib/e_plat/resource/collection.rb', line 31

def previous_page_info
	return unless pagination_available?
	extract_page_info(@previous)
end