diff --git a/TODO b/TODO index 8b1f773..24ef602 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ * Rails 3.1 Implementation - - * Kill &block stuff. * Make association conditions use pure SQL. Avoid 100s of IDs. diff --git a/lib/grouped_scope/self_grouping.rb b/lib/grouped_scope/self_grouping.rb index bf43ceb..927d3d2 100644 --- a/lib/grouped_scope/self_grouping.rb +++ b/lib/grouped_scope/self_grouping.rb @@ -65,9 +65,13 @@ def proxy_class private - def method_missing(method, *args, &block) + def method_missing(method, *args) if proxy_class.grouped_reflections[method] - proxy_owner.send :"grouped_scope_#{method}", *args, &block + if block_given? + proxy_owner.send(:"grouped_scope_#{method}", *args) { |*block_args| yield(*block_args) } + else + proxy_owner.send(:"grouped_scope_#{method}", *args) + end else super end diff --git a/test/helper.rb b/test/helper.rb index 74a22bb..42b7621 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -75,8 +75,8 @@ def assert_queries(num = 1) assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}" end - def assert_no_queries(&block) - assert_queries(0, &block) + def assert_no_queries + assert_queries(0) { yield } end def setup_database(options)