Class: Pastvu::Collection
- Inherits:
-
BasicResponse
- Object
- BasicResponse
- Pastvu::Collection
- Includes:
- Enumerable
- Defined in:
- lib/pastvu/collection.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasicResponse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(attr) ⇒ Collection
constructor
A new instance of Collection.
Methods inherited from BasicResponse
Constructor Details
#initialize(attr) ⇒ Collection
Returns a new instance of Collection.
5 6 7 |
# File 'lib/pastvu/collection.rb', line 5 def initialize(attr) attr.instance_of?(Hash) ? @hash = attr : super end |
Instance Method Details
#each ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pastvu/collection.rb', line 9 def each return to_enum(:each) unless block_given? @hash ||= self.to_hash reduce_hash.each do |model_hash| yield @model.new model_hash end end |