Class: Timeful::RelationProxy
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Timeful::RelationProxy
- Defined in:
- lib/timeful/relation_proxy.rb
Overview
Makes Array
behave much like ActiveRecord::Relation
.
This proxy class wraps an Array
or ActiveRecord::Relation
instance and makes the former behave like the latter by simulating methods like find_each
.
Instance Method Summary collapse
-
#find_each(*args) {|item| ... } ⇒ Object
If
find_each
is defined on the object we’re delegating to (i.e. the object is an instance ofActiveRecord::Relation
), calls it on the object.
Instance Method Details
#find_each(*args) {|item| ... } ⇒ Object
If find_each
is defined on the object we’re delegating to (i.e. the object is an instance of ActiveRecord::Relation
), calls it on the object.
Otherwise, calls each
on the object and yields the values.
16 17 18 19 20 21 22 23 24 |
# File 'lib/timeful/relation_proxy.rb', line 16 def find_each(*args, &block) method = if __getobj__.respond_to?(:find_each) :find_each else :each end __getobj__.send(method, *args, &block) end |