Class: Clicksign::Resource::QueryProxy
- Inherits:
-
Object
- Object
- Clicksign::Resource::QueryProxy
- Includes:
- Enumerable
- Defined in:
- lib/clicksign/resource.rb
Instance Method Summary collapse
- #auto_paging ⇒ Object
- #auto_paging_each(&block) ⇒ Object
- #count ⇒ Object
- #each(&block) ⇒ Object
- #each_page(&block) ⇒ Object
- #fields(**types) ⇒ Object
- #filter(**params) ⇒ Object
- #first ⇒ Object
- #include(*types) ⇒ Object
-
#initialize(resource_class, builder) ⇒ QueryProxy
constructor
A new instance of QueryProxy.
- #last ⇒ Object
- #order(field) ⇒ Object
- #page(number) ⇒ Object
- #per(size) ⇒ Object
- #to_a ⇒ Object
- #with_includes(*types) ⇒ Object
Constructor Details
#initialize(resource_class, builder) ⇒ QueryProxy
Returns a new instance of QueryProxy.
8 9 10 11 |
# File 'lib/clicksign/resource.rb', line 8 def initialize(resource_class, builder) @resource_class = resource_class @builder = builder end |
Instance Method Details
#auto_paging ⇒ Object
81 82 83 |
# File 'lib/clicksign/resource.rb', line 81 def auto_paging enum_for(:auto_paging_each) end |
#auto_paging_each(&block) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/clicksign/resource.rb', line 67 def auto_paging_each(&block) return enum_for(:auto_paging_each) unless block_given? @resource_class.send(:fetch_auto_pages, @builder.to_params) do |page| page.each(&block) end end |
#count ⇒ Object
59 60 61 |
# File 'lib/clicksign/resource.rb', line 59 def count to_a.size end |
#each(&block) ⇒ Object
63 64 65 |
# File 'lib/clicksign/resource.rb', line 63 def each(&block) to_a.each(&block) end |
#each_page(&block) ⇒ Object
75 76 77 78 79 |
# File 'lib/clicksign/resource.rb', line 75 def each_page(&block) return enum_for(:each_page) unless block_given? @resource_class.send(:fetch_auto_pages, @builder.to_params, &block) end |
#fields(**types) ⇒ Object
42 43 44 45 |
# File 'lib/clicksign/resource.rb', line 42 def fields(**types) @builder.fields(**types) self end |
#filter(**params) ⇒ Object
13 14 15 16 |
# File 'lib/clicksign/resource.rb', line 13 def filter(**params) @builder.filter(**params) self end |
#first ⇒ Object
51 52 53 |
# File 'lib/clicksign/resource.rb', line 51 def first to_a.first end |
#include(*types) ⇒ Object
23 24 25 |
# File 'lib/clicksign/resource.rb', line 23 def include(*types) with_includes(*types) end |
#last ⇒ Object
55 56 57 |
# File 'lib/clicksign/resource.rb', line 55 def last to_a.last end |
#order(field) ⇒ Object
27 28 29 30 |
# File 'lib/clicksign/resource.rb', line 27 def order(field) @builder.order(field) self end |
#page(number) ⇒ Object
32 33 34 35 |
# File 'lib/clicksign/resource.rb', line 32 def page(number) @builder.page(number) self end |
#per(size) ⇒ Object
37 38 39 40 |
# File 'lib/clicksign/resource.rb', line 37 def per(size) @builder.per(size) self end |
#to_a ⇒ Object
47 48 49 |
# File 'lib/clicksign/resource.rb', line 47 def to_a @resource_class.send(:fetch_list, @builder.to_params) end |
#with_includes(*types) ⇒ Object
18 19 20 21 |
# File 'lib/clicksign/resource.rb', line 18 def with_includes(*types) @builder.include(*types) self end |