module FacebookAds::EdgeHasGet
Constants
- DEFAULT_PAGE_SIZE
Attributes
has_next_page[RW]
next_page_cursor[RW]
Public Instance Methods
[](idx)
click to toggle source
# File lib/facebook_ads/edge.rb, line 29 def [](idx) # TODO Handle delegate fetch_next_page until idx < collection.length || !has_next_page? collection[idx] end
all()
click to toggle source
# File lib/facebook_ads/edge.rb, line 35 def all fetch_next_page until !has_next_page? collection end
each() { |e| ... }
click to toggle source
# File lib/facebook_ads/edge.rb, line 40 def each return enum_for(:each) unless block_given? idx = 0 while (e = self[idx]) yield e idx += 1 end self end
reload!()
click to toggle source
# File lib/facebook_ads/edge.rb, line 53 def reload! @collection = Array.new self.has_next_page = true self.next_page_cursor = nil end
Private Instance Methods
collection()
click to toggle source
# File lib/facebook_ads/edge.rb, line 77 def collection @collection ||= Array.new end
fetch_next_page()
click to toggle source
# File lib/facebook_ads/edge.rb, line 60 def fetch_next_page fetch_options = {limit: DEFAULT_PAGE_SIZE}.merge(serialized_options) fetch_options = fetch_options.merge({after: next_page_cursor}) if next_page_cursor node.get_edge(name, fetch_options) do |response| response["data"].each do |data| field_type = self.class.return_types[:get] obj = field_type.deserialize(data, node.session) collection << obj end self.next_page_cursor = response.dig('paging', 'cursors', 'after') self.has_next_page = !(response['data'].length < fetch_options[:limit]) end end
has_next_page?()
click to toggle source
# File lib/facebook_ads/edge.rb, line 81 def has_next_page? self.has_next_page.nil? ? (self.has_next_page = true) : self.has_next_page end
loaded?()
click to toggle source
# File lib/facebook_ads/edge.rb, line 85 def loaded? @loaded end