Class: RubyLokaliseApi::Collections::V1::Base
- Inherits:
-
Object
- Object
- RubyLokaliseApi::Collections::V1::Base
- Extended by:
- Forwardable, RubyLokaliseApi::Concerns::AttrsLoadable, Utils::Attributes
- Includes:
- Enumerable, Utils::Keys
- Defined in:
- lib/ruby_lokalise_api/collections/v1/base.rb
Overview
Base collection. Collection is an array of resources. The actual resources can be found
by calling the .collection method
Direct Known Subclasses
Constant Summary collapse
- ATTRS_FILENAME =
'collection_attributes.yml'
Constants included from Utils::Attributes
Utils::Attributes::UNIFIED_RESOURCES
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#has_more ⇒ Object
readonly
Returns the value of attribute has_more.
-
#next_cursor ⇒ Object
readonly
Returns the value of attribute next_cursor.
Instance Method Summary collapse
-
#initialize(response) ⇒ Base
constructor
A new instance of Base.
-
#load_next_cursor ⇒ Object
Tries to fetch the next cursor for paginated collection Returns a new collection or nil if the next cursor is not available.
-
#next_cursor? ⇒ Boolean
Checks whether the next cursor is available.
Methods included from RubyLokaliseApi::Concerns::AttrsLoadable
Methods included from Utils::Keys
#collection_key_for, #data_key_for
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
23 24 25 26 27 28 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 23 def initialize(response) @self_endpoint = response.endpoint populate_common_attrs_from response produce_collection_from response end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
21 22 23 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21 def collection @collection end |
#has_more ⇒ Object (readonly)
Returns the value of attribute has_more.
21 22 23 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21 def has_more @has_more end |
#next_cursor ⇒ Object (readonly)
Returns the value of attribute next_cursor.
21 22 23 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21 def next_cursor @next_cursor end |
Instance Method Details
#load_next_cursor ⇒ Object
Tries to fetch the next cursor for paginated collection Returns a new collection or nil if the next cursor is not available
32 33 34 35 36 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 32 def load_next_cursor return nil unless next_cursor? fetch_cursor(next_cursor) end |
#next_cursor? ⇒ Boolean
Checks whether the next cursor is available
40 41 42 |
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 40 def next_cursor? !next_cursor.nil? && next_cursor != '' end |