diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 17:55:49 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 17:55:49 -0700 |
commit | 78b5b5783776f57a47e480db4bd83b15db988909 (patch) | |
tree | b0263e5e9f1f6b71bb69b4009d24c2d072910a2c /lib/arel | |
parent | e8966bf9a86afb82c658cedd7e4baffa3a15a856 (diff) | |
download | rails-78b5b5783776f57a47e480db4bd83b15db988909.tar.gz rails-78b5b5783776f57a47e480db4bd83b15db988909.tar.bz2 rails-78b5b5783776f57a47e480db4bd83b15db988909.zip |
some convenience methods
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/arel.rb | 3 | ||||
-rw-r--r-- | lib/arel/relations/relation.rb | 20 |
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/arel/arel.rb b/lib/arel/arel.rb new file mode 100644 index 0000000000..892be854ee --- /dev/null +++ b/lib/arel/arel.rb @@ -0,0 +1,3 @@ +def Arel(name, engine = Arel::Table.engine) + Arel::Table.new(name, engine) +end
\ No newline at end of file diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 4440fb1c1d..6e0413232f 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -57,26 +57,26 @@ module Arel include Enumerable module Operable - def join(other = nil, join_type = "INNER JOIN") - case other + def join(other_relation = nil, join_type = "INNER JOIN") + case other_relation when String - Join.new(other, self) + Join.new(other_relation, self) when Relation - JoinOperation.new(join_type, self, other) + JoinOperation.new(join_type, self, other_relation) else self end end - def outer_join(other = nil) - join(other, "LEFT OUTER JOIN") + def outer_join(other_relation = nil) + join(other_relation, "LEFT OUTER JOIN") end - def where(*predicates) + def where(*predicates, &block) predicates.all?(&:blank?) ? self : Where.new(self, *predicates) end - def project(*attributes) + def project(*attributes, &block) attributes.all?(&:blank?) ? self : Project.new(self, *attributes) end @@ -84,7 +84,7 @@ module Arel Alias.new(self) end - def order(*attributes) + def order(*attributes, &block) attributes.all?(&:blank?) ? self : Order.new(self, *attributes) end @@ -96,7 +96,7 @@ module Arel skipped.blank?? self : Skip.new(self, skipped) end - def group(*groupings) + def group(*groupings, &block) groupings.all?(&:blank?) ? self : Group.new(self, *groupings) end |