Class: NexaasID::Entities::Collection
- Extended by:
- Forwardable
- Defined in:
- lib/nexaas_id/entities/collection.rb
Constant Summary collapse
- PAGE_REGEX =
/page=(\d+)/
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(response, entity_class) ⇒ Collection
constructor
A new instance of Collection.
- #next_page ⇒ Object
- #previous_page ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(response, entity_class) ⇒ Collection
9 10 11 12 13 14 |
# File 'lib/nexaas_id/entities/collection.rb', line 9 def initialize(response, entity_class) @response = response @entity_class = entity_class @total = parsed_body['count'].to_i @collection = [] end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/nexaas_id/entities/collection.rb', line 6 def total @total end |
Class Method Details
.build(response, entity_class) ⇒ Object
16 17 18 |
# File 'lib/nexaas_id/entities/collection.rb', line 16 def self.build(response, entity_class) self.new(response, entity_class).build end |
Instance Method Details
#build ⇒ Object
20 21 22 23 |
# File 'lib/nexaas_id/entities/collection.rb', line 20 def build build_collection self end |
#next_page ⇒ Object
25 26 27 |
# File 'lib/nexaas_id/entities/collection.rb', line 25 def next_page page_for('next') end |
#previous_page ⇒ Object
29 30 31 |
# File 'lib/nexaas_id/entities/collection.rb', line 29 def previous_page page_for('previous') end |
#to_a ⇒ Object
33 34 35 |
# File 'lib/nexaas_id/entities/collection.rb', line 33 def to_a @collection.clone end |