@@ -662,25 +662,25 @@ def count
662662 # @yield a block yield for each object in the result
663663 # @return [Array]
664664 # @see Array#each
665- def each
665+ def each ( & block )
666666 return results . enum_for ( :each ) unless block_given? # Sparkling magic!
667- results . each ( &Proc . new )
667+ results . each ( &block )
668668 end
669669
670670 # @yield a block yield for each object in the result
671671 # @return [Array]
672672 # @see Array#map
673- def map
673+ def map ( & block )
674674 return results . enum_for ( :map ) unless block_given? # Sparkling magic!
675- results . map ( &Proc . new )
675+ results . map ( &block )
676676 end
677677
678678 # @yield a block yield for each object in the result
679679 # @return [Array]
680680 # @see Array#select
681- def select
681+ def select ( & block )
682682 return results . enum_for ( :select ) unless block_given? # Sparkling magic!
683- results . select ( &Proc . new )
683+ results . select ( &block )
684684 end
685685
686686 # @return [Array]
@@ -700,7 +700,7 @@ def first(limit = 1)
700700 # max_results is used to iterate through as many API requests as possible using
701701 # :skip and :limit paramter.
702702 # @!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 )
704704 compiled_query = compile
705705 batch_size = 1_000
706706 results = [ ]
@@ -725,7 +725,7 @@ def max_results(raw: false, on_batch: nil, discard_results: false)
725725 items = decode ( items ) unless raw
726726 # if a block is provided, we do not keep the results after processing.
727727 if block_given?
728- items . each ( &Proc . new )
728+ items . each ( &block )
729729 else
730730 # concat results unless discard_results is true
731731 results += items unless discard_results
@@ -796,15 +796,15 @@ def fetch!(compiled_query)
796796 # @yield a block to iterate for each object that matched the query.
797797 # @return [Array<Hash>] if raw is set to true, a set of Parse JSON hashes.
798798 # @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 )
800800 if @results . nil?
801801 if block_given?
802- max_results ( raw : raw , &Proc . new )
802+ max_results ( raw : raw , &block )
803803 elsif @limit . is_a? ( Numeric )
804804 response = fetch! ( compile )
805805 return [ ] if response . error?
806806 items = raw ? response . results : decode ( response . results )
807- return items . each ( &Proc . new ) if block_given?
807+ return items . each ( &block ) if block_given?
808808 @results = items
809809 else
810810 @results = max_results ( raw : raw )
@@ -822,9 +822,9 @@ def results(raw: false)
822822 # @return [Array<Hash>] if raw is set to true, a set of Parse JSON hashes.
823823 # @return [Array<Parse::Object>] if raw is set to false, a list of matching Parse::Object subclasses.
824824 # @see #results
825- def all ( expressions = { limit : :max } )
825+ def all ( expressions = { limit : :max } , & block )
826826 conditions ( expressions )
827- return results ( &Proc . new ) if block_given?
827+ return results ( &block ) if block_given?
828828 results
829829 end
830830
0 commit comments