Class: Harpy::Collection
- Inherits:
-
Object
- Object
- Harpy::Collection
- Includes:
- Resource
- Defined in:
- lib/harpy/collection.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
(also: #item, #to_a, #to_ary)
readonly
Returns the value of attribute items.
Instance Method Summary collapse
-
#initialize(attrs = nil) ⇒ Collection
constructor
A new instance of Collection.
- #persisted? ⇒ Boolean
Methods included from Resource
Constructor Details
#initialize(attrs = nil) ⇒ Collection
Returns a new instance of Collection.
5 6 7 8 9 |
# File 'lib/harpy/collection.rb', line 5 def initialize(attrs = nil) attrs = attrs || {} @items = attrs.delete :items super attrs end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (private)
17 18 19 20 21 22 23 24 |
# File 'lib/harpy/collection.rb', line 17 def method_missing(method, *args, &blk) if items.respond_to? method result = items.send method, *args, &blk result===items ? self : result else super end end |
Instance Attribute Details
#items ⇒ Object (readonly) Also known as: item, to_a, to_ary
Returns the value of attribute items.
4 5 6 |
# File 'lib/harpy/collection.rb', line 4 def items @items end |
Instance Method Details
#persisted? ⇒ Boolean
10 11 12 |
# File 'lib/harpy/collection.rb', line 10 def persisted? true end |