@@ -662,25 +662,25 @@ def count
662
662
# @yield a block yield for each object in the result
663
663
# @return [Array]
664
664
# @see Array#each
665
- def each
665
+ def each ( & block )
666
666
return results . enum_for ( :each ) unless block_given? # Sparkling magic!
667
- results . each ( &Proc . new )
667
+ results . each ( &block )
668
668
end
669
669
670
670
# @yield a block yield for each object in the result
671
671
# @return [Array]
672
672
# @see Array#map
673
- def map
673
+ def map ( & block )
674
674
return results . enum_for ( :map ) unless block_given? # Sparkling magic!
675
- results . map ( &Proc . new )
675
+ results . map ( &block )
676
676
end
677
677
678
678
# @yield a block yield for each object in the result
679
679
# @return [Array]
680
680
# @see Array#select
681
- def select
681
+ def select ( & block )
682
682
return results . enum_for ( :select ) unless block_given? # Sparkling magic!
683
- results . select ( &Proc . new )
683
+ results . select ( &block )
684
684
end
685
685
686
686
# @return [Array]
@@ -700,7 +700,7 @@ def first(limit = 1)
700
700
# max_results is used to iterate through as many API requests as possible using
701
701
# :skip and :limit paramter.
702
702
# @!visibility private
703
- def max_results ( raw : false , on_batch : nil , discard_results : false )
703
+ def max_results ( raw : false , on_batch : nil , discard_results : false , & block )
704
704
compiled_query = compile
705
705
batch_size = 1_000
706
706
results = [ ]
@@ -725,7 +725,7 @@ def max_results(raw: false, on_batch: nil, discard_results: false)
725
725
items = decode ( items ) unless raw
726
726
# if a block is provided, we do not keep the results after processing.
727
727
if block_given?
728
- items . each ( &Proc . new )
728
+ items . each ( &block )
729
729
else
730
730
# concat results unless discard_results is true
731
731
results += items unless discard_results
@@ -796,15 +796,15 @@ def fetch!(compiled_query)
796
796
# @yield a block to iterate for each object that matched the query.
797
797
# @return [Array<Hash>] if raw is set to true, a set of Parse JSON hashes.
798
798
# @return [Array<Parse::Object>] if raw is set to false, a list of matching Parse::Object subclasses.
799
- def results ( raw : false )
799
+ def results ( raw : false , & block )
800
800
if @results . nil?
801
801
if block_given?
802
- max_results ( raw : raw , &Proc . new )
802
+ max_results ( raw : raw , &block )
803
803
elsif @limit . is_a? ( Numeric )
804
804
response = fetch! ( compile )
805
805
return [ ] if response . error?
806
806
items = raw ? response . results : decode ( response . results )
807
- return items . each ( &Proc . new ) if block_given?
807
+ return items . each ( &block ) if block_given?
808
808
@results = items
809
809
else
810
810
@results = max_results ( raw : raw )
@@ -822,9 +822,9 @@ def results(raw: false)
822
822
# @return [Array<Hash>] if raw is set to true, a set of Parse JSON hashes.
823
823
# @return [Array<Parse::Object>] if raw is set to false, a list of matching Parse::Object subclasses.
824
824
# @see #results
825
- def all ( expressions = { limit : :max } )
825
+ def all ( expressions = { limit : :max } , & block )
826
826
conditions ( expressions )
827
- return results ( &Proc . new ) if block_given?
827
+ return results ( &block ) if block_given?
828
828
results
829
829
end
830
830
0 commit comments