Class: RatingChgkV2::Collections::BaseCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/rating_chgk_v2/collections/base_collection.rb

Overview

Base class for all collections. A collection contains an array of models, for example a collection of players, tournaments, or regions. Some collections are paginated but not all.

Constant Summary collapse

MODEL =
''

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data, endpoint = nil) ⇒ BaseCollection

Returns a new instance of BaseCollection.



26
27
28
# File 'lib/rating_chgk_v2/collections/base_collection.rb', line 26

def initialize(raw_data, endpoint = nil)
  setup raw_data, endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



12
13
14
# File 'lib/rating_chgk_v2/collections/base_collection.rb', line 12

def endpoint
  @endpoint
end

#itemsObject (readonly)

Returns the value of attribute items.



12
13
14
# File 'lib/rating_chgk_v2/collections/base_collection.rb', line 12

def items
  @items
end

Class Method Details

.load(method, endpoint) ⇒ Object



17
18
19
# File 'lib/rating_chgk_v2/collections/base_collection.rb', line 17

def load(method, endpoint)
  new endpoint.send(method), endpoint
end

.paginatedObject



21
22
23
# File 'lib/rating_chgk_v2/collections/base_collection.rb', line 21

def paginated
  include RatingChgkV2::Concerns::Paginated
end