class AutotaskApi::EntityCollection
Constants
- PAGE_SIZE
Attributes
class_name[R]
client[R]
condition[RW]
entities[R]
Public Class Methods
new(class_name, entities, condition, client = AutotaskApi.client)
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 11 def initialize(class_name, entities, condition, client = AutotaskApi.client) @class_name = class_name @entities = entities @condition = condition @client = client end
Public Instance Methods
each(&block)
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 18 def each(&block) entities.each(&block) end
empty?()
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 41 def empty? entities.empty? end
last(&block)
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 22 def last(&block) entities.last(&block) end
next_page()
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 30 def next_page new_expression = Expression.new('id', 'GreaterThan', entities.last[:id]) condition.remove_expression_by_field('id') params = condition.expressions.empty? ? new_expression : [condition, new_expression] new_condition = Condition.new(params) class_name.where(new_condition, client) end
next_page?()
click to toggle source
# File lib/autotask_api/entity_collection.rb, line 26 def next_page? entities.size >= PAGE_SIZE end