From d05fa0cc8da0ffa01333f8956acd4a24c9fd46be Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 24 Jun 2010 09:51:23 -0300 Subject: Improve blocks usage. --- lib/arel/algebra/relations/operations/having.rb | 2 +- lib/arel/algebra/relations/operations/lock.rb | 2 +- lib/arel/algebra/relations/operations/where.rb | 2 +- lib/arel/algebra/relations/relation.rb | 4 ++-- lib/arel/algebra/relations/utilities/compound.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/arel/algebra/relations/operations/having.rb b/lib/arel/algebra/relations/operations/having.rb index 0cd86c284e..a1bbbb3bdc 100644 --- a/lib/arel/algebra/relations/operations/having.rb +++ b/lib/arel/algebra/relations/operations/having.rb @@ -4,7 +4,7 @@ module Arel deriving :== requires :restricting - def initialize(relation, *predicates, &block) + def initialize(relation, *predicates) predicates = [yield(relation)] + predicates if block_given? @predicates = predicates.map { |p| p.bind(relation) } @relation = relation diff --git a/lib/arel/algebra/relations/operations/lock.rb b/lib/arel/algebra/relations/operations/lock.rb index 0d6c12e65b..2da273cebc 100644 --- a/lib/arel/algebra/relations/operations/lock.rb +++ b/lib/arel/algebra/relations/operations/lock.rb @@ -3,7 +3,7 @@ module Arel attributes :relation, :locked deriving :initialize, :== - def initialize(relation, locked, &block) + def initialize(relation, locked) @relation = relation @locked = locked.blank? ? " FOR UPDATE" : locked end diff --git a/lib/arel/algebra/relations/operations/where.rb b/lib/arel/algebra/relations/operations/where.rb index 5c50fe8640..9d868ac18b 100644 --- a/lib/arel/algebra/relations/operations/where.rb +++ b/lib/arel/algebra/relations/operations/where.rb @@ -4,7 +4,7 @@ module Arel deriving :== requires :restricting - def initialize(relation, *predicates, &block) + def initialize(relation, *predicates) predicates = [yield(relation)] + predicates if block_given? @predicates = predicates.map { |p| p.bind(relation) } @relation = relation diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index ffd31ae470..0332482066 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -17,8 +17,8 @@ module Arel module Enumerable include ::Enumerable - def each(&block) - session.read(self).each(&block) + def each + session.read(self).each { |e| yield e } end def first diff --git a/lib/arel/algebra/relations/utilities/compound.rb b/lib/arel/algebra/relations/utilities/compound.rb index 416717310c..9f653bbafb 100644 --- a/lib/arel/algebra/relations/utilities/compound.rb +++ b/lib/arel/algebra/relations/utilities/compound.rb @@ -47,7 +47,7 @@ module Arel private - def arguments_from_block(relation, &block) + def arguments_from_block(relation) block_given?? [yield(relation)] : [] end end -- cgit v1.2.3