diff options
Diffstat (limited to 'lib/arel/algebra/relations/relation.rb')
-rw-r--r-- | lib/arel/algebra/relations/relation.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index ccc1ab558f..e8ef9b395d 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -116,7 +116,7 @@ module Arel end %w{ - where project order skip group having + where order skip group having }.each do |operation_name| class_eval <<-OPERATION, __FILE__, __LINE__ def #{operation_name}(*arguments) @@ -126,6 +126,11 @@ module Arel OPERATION end + def project *args + return self if args.all? { |x| x.blank? } + Project.new self, *args + end + def take thing Take.new self, thing end @@ -142,20 +147,17 @@ module Arel Alias.new(self) end - module Writable - def insert(record) - session.create Insert.new(self, record) - end + def insert(record) + session.create Insert.new(self, record) + end - def update(assignments) - session.update Update.new(self, assignments) - end + def update(assignments) + session.update Update.new(self, assignments) + end - def delete - session.delete Deletion.new(self) - end + def delete + session.delete Deletion.new(self) end - include Writable JoinOperation = Struct.new(:join_class, :relation1, :relation2) do def on(*predicates) |