Class: Horza::Entities::Collection
- Inherits:
-
Object
- Object
- Horza::Entities::Collection
show all
- Defined in:
- lib/horza/entities/collection.rb
Instance Method Summary
collapse
Constructor Details
#initialize(collection) ⇒ Collection
4
5
6
|
# File 'lib/horza/entities/collection.rb', line 4
def initialize(collection)
@collection = collection
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/horza/entities/collection.rb', line 14
def method_missing(method, &block)
if [:length, :size, :empty?, :present?].include? method
@collection.send(method)
elsif [:first, :last].include? method
singular_entity(@collection.send(method))
elsif [:each, :map, :collect]
enum_method(method, &block)
end
end
|
Instance Method Details
#[](index) ⇒ Object
8
9
10
|
# File 'lib/horza/entities/collection.rb', line 8
def [](index)
singular_entity(@collection[index])
end
|