From b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 14:38:09 -0400 Subject: consolidated files Conflicts: lib/arel/algebra/predicates.rb lib/arel/algebra/relations/writes/delete.rb lib/arel/algebra/relations/writes/insert.rb lib/arel/algebra/relations/writes/update.rb lib/arel/engines/memory/predicates.rb lib/arel/engines/memory/relations.rb lib/arel/engines/sql/primitives/attribute.rb lib/arel/engines/sql/relations/writes/insert.rb lib/arel/engines/sql/relations/writes/update.rb --- lib/arel/algebra/predicates.rb | 30 +++++++++++------------- lib/arel/algebra/relations.rb | 4 +--- lib/arel/algebra/relations/writes.rb | 36 +++++++++++++++++++++++++++++ lib/arel/algebra/relations/writes/delete.rb | 10 -------- lib/arel/algebra/relations/writes/insert.rb | 14 ----------- lib/arel/algebra/relations/writes/update.rb | 14 ----------- 6 files changed, 50 insertions(+), 58 deletions(-) create mode 100644 lib/arel/algebra/relations/writes.rb delete mode 100644 lib/arel/algebra/relations/writes/delete.rb delete mode 100644 lib/arel/algebra/relations/writes/insert.rb delete mode 100644 lib/arel/algebra/relations/writes/update.rb (limited to 'lib/arel/algebra') diff --git a/lib/arel/algebra/predicates.rb b/lib/arel/algebra/predicates.rb index f83101306e..7f093ded6d 100644 --- a/lib/arel/algebra/predicates.rb +++ b/lib/arel/algebra/predicates.rb @@ -1,5 +1,12 @@ module Arel class Predicate + def or(other_predicate) + Or.new(self, other_predicate) + end + + def and(other_predicate) + And.new(self, other_predicate) + end end class Binary < Predicate @@ -25,21 +32,10 @@ module Arel end end - class GreaterThanOrEqualTo < Binary - end - - class GreaterThan < Binary - end - - class LessThanOrEqualTo < Binary - end - - class LessThan < Binary - end - - class Match < Binary - end - - class In < Binary - end + class GreaterThanOrEqualTo < Binary; end + class GreaterThan < Binary; end + class LessThanOrEqualTo < Binary; end + class LessThan < Binary; end + class Match < Binary; end + class In < Binary; end end \ No newline at end of file diff --git a/lib/arel/algebra/relations.rb b/lib/arel/algebra/relations.rb index 03f04d2459..b75a31e5e3 100644 --- a/lib/arel/algebra/relations.rb +++ b/lib/arel/algebra/relations.rb @@ -2,9 +2,7 @@ require 'arel/algebra/relations/relation' require 'arel/algebra/relations/utilities/compound' require 'arel/algebra/relations/utilities/nil' require 'arel/algebra/relations/utilities/externalization' -require 'arel/algebra/relations/writes/delete' -require 'arel/algebra/relations/writes/update' -require 'arel/algebra/relations/writes/insert' +require 'arel/algebra/relations/writes' require 'arel/algebra/relations/operations/alias' require 'arel/algebra/relations/operations/group' require 'arel/algebra/relations/operations/join' diff --git a/lib/arel/algebra/relations/writes.rb b/lib/arel/algebra/relations/writes.rb new file mode 100644 index 0000000000..352f7bc7e5 --- /dev/null +++ b/lib/arel/algebra/relations/writes.rb @@ -0,0 +1,36 @@ +module Arel + class Deletion < Compound + attributes :relation + deriving :initialize, :== + + def call + engine.delete(self) + end + end + + class Insert < Compound + attributes :relation, :record + deriving :== + + def initialize(relation, record) + @relation, @record = relation, record.bind(relation) + end + + def call + engine.create(self) + end + end + + class Update < Compound + attributes :relation, :assignments + deriving :== + + def initialize(relation, assignments) + @relation, @assignments = relation, assignments.bind(relation) + end + + def call + engine.update(self) + end + end +end \ No newline at end of file diff --git a/lib/arel/algebra/relations/writes/delete.rb b/lib/arel/algebra/relations/writes/delete.rb deleted file mode 100644 index a94067c7fa..0000000000 --- a/lib/arel/algebra/relations/writes/delete.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Arel - class Deletion < Compound - attributes :relation - deriving :initialize, :== - - def call - engine.delete(self) - end - end -end diff --git a/lib/arel/algebra/relations/writes/insert.rb b/lib/arel/algebra/relations/writes/insert.rb deleted file mode 100644 index 6d85e9769a..0000000000 --- a/lib/arel/algebra/relations/writes/insert.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Arel - class Insert < Compound - attributes :relation, :record - deriving :== - - def initialize(relation, record) - @relation, @record = relation, record.bind(relation) - end - - def call - engine.create(self) - end - end -end diff --git a/lib/arel/algebra/relations/writes/update.rb b/lib/arel/algebra/relations/writes/update.rb deleted file mode 100644 index e647218a80..0000000000 --- a/lib/arel/algebra/relations/writes/update.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Arel - class Update < Compound - attributes :relation, :assignments - deriving :== - - def initialize(relation, assignments) - @relation, @assignments = relation, assignments - end - - def call - engine.update(self) - end - end -end -- cgit v1.2.3