Module: ContentfulModel::Queries::ClassMethods
- Defined in:
- lib/contentful_model/queries.rb
Overview
Class methods for Queries
Instance Method Summary collapse
- #all ⇒ Object
- #each_entry(per_page = 100, order_field = 'sys.updatedAt', additional_options = {}, &block) ⇒ Object
- #each_page(per_page = 100, order_field = 'sys.updatedAt', additional_options = {}, &block) ⇒ Object
- #find(id) ⇒ Object
- #find_by(find_query = {}) ⇒ Object
- #first ⇒ Object
- #limit(n) ⇒ Object
- #load ⇒ Object
- #load_children(n) ⇒ Object
- #locale(locale_code) ⇒ Object
- #offset(n) ⇒ Object (also: #skip)
- #order(args) ⇒ Object
- #paginate(page = 1, per_page = 100, order_field = 'sys.updatedAt', additional_options = {}) ⇒ Object
- #params(options) ⇒ Object
- #query ⇒ Object
- #search(parameters) ⇒ Object
Instance Method Details
#all ⇒ Object
16 17 18 19 |
# File 'lib/contentful_model/queries.rb', line 16 def all fail ArgumentError, 'You need to set self.content_type in your model class' if @content_type_id.nil? query end |
#each_entry(per_page = 100, order_field = 'sys.updatedAt', additional_options = {}, &block) ⇒ Object
54 55 56 |
# File 'lib/contentful_model/queries.rb', line 54 def each_entry(per_page = 100, order_field = 'sys.updatedAt', = {}, &block) query.each_entry(per_page, order_field, , &block) end |
#each_page(per_page = 100, order_field = 'sys.updatedAt', additional_options = {}, &block) ⇒ Object
50 51 52 |
# File 'lib/contentful_model/queries.rb', line 50 def each_page(per_page = 100, order_field = 'sys.updatedAt', = {}, &block) query.each_page(per_page, order_field, , &block) end |
#find(id) ⇒ Object
66 67 68 |
# File 'lib/contentful_model/queries.rb', line 66 def find(id) query.find(id) end |
#find_by(find_query = {}) ⇒ Object
70 71 72 |
# File 'lib/contentful_model/queries.rb', line 70 def find_by(find_query = {}) query.find_by(find_query) end |
#first ⇒ Object
25 26 27 |
# File 'lib/contentful_model/queries.rb', line 25 def first query.first end |
#limit(n) ⇒ Object
38 39 40 |
# File 'lib/contentful_model/queries.rb', line 38 def limit(n) query.limit(n) end |
#load ⇒ Object
21 22 23 |
# File 'lib/contentful_model/queries.rb', line 21 def load all.load end |
#load_children(n) ⇒ Object
58 59 60 |
# File 'lib/contentful_model/queries.rb', line 58 def load_children(n) query.load_children(n) end |
#locale(locale_code) ⇒ Object
42 43 44 |
# File 'lib/contentful_model/queries.rb', line 42 def locale(locale_code) query.locale(locale_code) end |
#offset(n) ⇒ Object Also known as: skip
33 34 35 |
# File 'lib/contentful_model/queries.rb', line 33 def offset(n) query.offset(n) end |
#order(args) ⇒ Object
62 63 64 |
# File 'lib/contentful_model/queries.rb', line 62 def order(args) query.order(args) end |
#paginate(page = 1, per_page = 100, order_field = 'sys.updatedAt', additional_options = {}) ⇒ Object
46 47 48 |
# File 'lib/contentful_model/queries.rb', line 46 def paginate(page = 1, per_page = 100, order_field = 'sys.updatedAt', = {}) query.paginate(page, per_page, order_field, ) end |
#params(options) ⇒ Object
29 30 31 |
# File 'lib/contentful_model/queries.rb', line 29 def params() query.params() end |
#query ⇒ Object
12 13 14 |
# File 'lib/contentful_model/queries.rb', line 12 def query ContentfulModel::Query.new(self) end |
#search(parameters) ⇒ Object
74 75 76 |
# File 'lib/contentful_model/queries.rb', line 74 def search(parameters) query.search(parameters) end |