Class: Locomotive::Coal::Resources::ContentEntries
- Defined in:
- lib/locomotive/coal/resources/content_entries.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
Attributes inherited from Base
Instance Method Summary collapse
- #each(query = nil, options = nil, locale = nil, &block) ⇒ Object
- #index(query = nil, options = {}, locale = nil) ⇒ Object (also: #all)
-
#initialize(uri, credentials, content_type) ⇒ ContentEntries
constructor
A new instance of ContentEntries.
Methods inherited from Base
#create, #destroy, #destroy_all, #update_with_locale
Methods included from Locomotive::Coal::Resources::Concerns::Request
#delete, #do_request, #get, #post, #put, #without_authentication
Constructor Details
#initialize(uri, credentials, content_type) ⇒ ContentEntries
Returns a new instance of ContentEntries.
9 10 11 12 |
# File 'lib/locomotive/coal/resources/content_entries.rb', line 9 def initialize(uri, credentials, content_type) @content_type = content_type super(uri, credentials) end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/locomotive/coal/resources/content_entries.rb', line 7 def content_type @content_type end |
Instance Method Details
#each(query = nil, options = nil, locale = nil, &block) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/locomotive/coal/resources/content_entries.rb', line 28 def each(query = nil, = nil, locale = nil, &block) page = 1 while page do resources = all(query, ( || {}).merge(page: page), locale) resources.each(&block) page = resources._next_page end end |
#index(query = nil, options = {}, locale = nil) ⇒ Object Also known as: all
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/locomotive/coal/resources/content_entries.rb', line 14 def index(query = nil, = {}, locale = nil) parameters = { where: (query || {}).to_json }.merge( || {}) parameters[:_locale] = locale if locale response = get(resources_name, parameters, true) list = response.body.map { |attributes| Resource.new(attributes) } PaginatedResources.new(list, [:page] || 1, response.headers[:x_total_pages].to_i, response.headers[:x_total_entries].to_i) end |