From 518db17ca3dade07fc67b6044b63c826cefb1442 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 19 May 2008 13:57:21 -0700 Subject: renamed ion classes --- lib/arel/relations.rb | 8 ++++---- lib/arel/relations/delete.rb | 25 +++++++++++++++++++++++++ lib/arel/relations/deletion.rb | 25 ------------------------- lib/arel/relations/group.rb | 19 +++++++++++++++++++ lib/arel/relations/grouping.rb | 19 ------------------- lib/arel/relations/insert.rb | 28 ++++++++++++++++++++++++++++ lib/arel/relations/insertion.rb | 28 ---------------------------- lib/arel/relations/project.rb | 23 +++++++++++++++++++++++ lib/arel/relations/projection.rb | 23 ----------------------- lib/arel/relations/relation.rb | 6 +++--- 10 files changed, 102 insertions(+), 102 deletions(-) create mode 100644 lib/arel/relations/delete.rb delete mode 100644 lib/arel/relations/deletion.rb create mode 100644 lib/arel/relations/group.rb delete mode 100644 lib/arel/relations/grouping.rb create mode 100644 lib/arel/relations/insert.rb delete mode 100644 lib/arel/relations/insertion.rb create mode 100644 lib/arel/relations/project.rb delete mode 100644 lib/arel/relations/projection.rb (limited to 'lib') diff --git a/lib/arel/relations.rb b/lib/arel/relations.rb index b606be3743..364235fb49 100644 --- a/lib/arel/relations.rb +++ b/lib/arel/relations.rb @@ -6,14 +6,14 @@ require 'arel/relations/writing' require 'arel/relations/table' require 'arel/relations/aggregation' require 'arel/relations/join' -require 'arel/relations/grouping' -require 'arel/relations/projection' +require 'arel/relations/group' +require 'arel/relations/project' require 'arel/relations/where' require 'arel/relations/order' require 'arel/relations/take' require 'arel/relations/skip' -require 'arel/relations/deletion' -require 'arel/relations/insertion' +require 'arel/relations/delete' +require 'arel/relations/insert' require 'arel/relations/update' require 'arel/relations/alias' require 'arel/sessions/session' \ No newline at end of file diff --git a/lib/arel/relations/delete.rb b/lib/arel/relations/delete.rb new file mode 100644 index 0000000000..7edc328e4a --- /dev/null +++ b/lib/arel/relations/delete.rb @@ -0,0 +1,25 @@ +module Arel + class Deletion < Writing + def initialize(relation) + @relation = relation + end + + def to_sql(formatter = nil) + [ + "DELETE", + "FROM #{table_sql}", + ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), + ("LIMIT #{taken}" unless taken.blank? ), + ].compact.join("\n") + end + + def call(connection = engine.connection) + connection.delete(to_sql) + end + + def ==(other) + Deletion === other and + relation == other.relation + end + end +end \ No newline at end of file diff --git a/lib/arel/relations/deletion.rb b/lib/arel/relations/deletion.rb deleted file mode 100644 index 7edc328e4a..0000000000 --- a/lib/arel/relations/deletion.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Arel - class Deletion < Writing - def initialize(relation) - @relation = relation - end - - def to_sql(formatter = nil) - [ - "DELETE", - "FROM #{table_sql}", - ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), - ("LIMIT #{taken}" unless taken.blank? ), - ].compact.join("\n") - end - - def call(connection = engine.connection) - connection.delete(to_sql) - end - - def ==(other) - Deletion === other and - relation == other.relation - end - end -end \ No newline at end of file diff --git a/lib/arel/relations/group.rb b/lib/arel/relations/group.rb new file mode 100644 index 0000000000..bc3a7f3437 --- /dev/null +++ b/lib/arel/relations/group.rb @@ -0,0 +1,19 @@ +module Arel + class Group < Compound + attr_reader :groupings + + def initialize(relation, *groupings) + @relation, @groupings = relation, groupings.collect { |g| g.bind(relation) } + end + + def ==(other) + Group === other and + relation == other.relation and + groupings == other.groupings + end + + def aggregation? + true + end + end +end \ No newline at end of file diff --git a/lib/arel/relations/grouping.rb b/lib/arel/relations/grouping.rb deleted file mode 100644 index de8643278b..0000000000 --- a/lib/arel/relations/grouping.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Arel - class Grouping < Compound - attr_reader :groupings - - def initialize(relation, *groupings) - @relation, @groupings = relation, groupings.collect { |g| g.bind(relation) } - end - - def ==(other) - Grouping === other and - relation == other.relation and - groupings == other.groupings - end - - def aggregation? - true - end - end -end \ No newline at end of file diff --git a/lib/arel/relations/insert.rb b/lib/arel/relations/insert.rb new file mode 100644 index 0000000000..b190ccb211 --- /dev/null +++ b/lib/arel/relations/insert.rb @@ -0,0 +1,28 @@ +module Arel + class Insert < Writing + attr_reader :record + + def initialize(relation, record) + @relation, @record = relation, record.bind(relation) + end + + def to_sql(formatter = nil) + [ + "INSERT", + "INTO #{table_sql}", + "(#{record.keys.collect(&:to_sql).join(', ')})", + "VALUES (#{record.collect { |key, value| key.format(value) }.join(', ')})" + ].join("\n") + end + + def call(connection = engine.connection) + connection.insert(to_sql) + end + + def ==(other) + Insert === other and + relation == other.relation and + record == other.record + end + end +end \ No newline at end of file diff --git a/lib/arel/relations/insertion.rb b/lib/arel/relations/insertion.rb deleted file mode 100644 index 16eb9b7555..0000000000 --- a/lib/arel/relations/insertion.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Arel - class Insertion < Writing - attr_reader :record - - def initialize(relation, record) - @relation, @record = relation, record.bind(relation) - end - - def to_sql(formatter = nil) - [ - "INSERT", - "INTO #{table_sql}", - "(#{record.keys.collect(&:to_sql).join(', ')})", - "VALUES (#{record.collect { |key, value| key.format(value) }.join(', ')})" - ].join("\n") - end - - def call(connection = engine.connection) - connection.insert(to_sql) - end - - def ==(other) - Insertion === other and - relation == other.relation and - record == other.record - end - end -end \ No newline at end of file diff --git a/lib/arel/relations/project.rb b/lib/arel/relations/project.rb new file mode 100644 index 0000000000..0efc13bdb3 --- /dev/null +++ b/lib/arel/relations/project.rb @@ -0,0 +1,23 @@ +module Arel + class Project < Compound + attr_reader :projections + + def initialize(relation, *projections) + @relation, @projections = relation, projections + end + + def attributes + @attributes ||= projections.collect { |p| p.bind(self) } + end + + def aggregation? + attributes.any?(&:aggregation?) + end + + def ==(other) + Project === other and + relation == other.relation and + projections == other.projections + end + end +end \ No newline at end of file diff --git a/lib/arel/relations/projection.rb b/lib/arel/relations/projection.rb deleted file mode 100644 index d74f111271..0000000000 --- a/lib/arel/relations/projection.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Arel - class Projection < Compound - attr_reader :projections - - def initialize(relation, *projections) - @relation, @projections = relation, projections - end - - def attributes - @attributes ||= projections.collect { |p| p.bind(self) } - end - - def aggregation? - attributes.any?(&:aggregation?) - end - - def ==(other) - Projection === other and - relation == other.relation and - projections == other.projections - end - end -end \ No newline at end of file diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 1ef7874f39..4440fb1c1d 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -77,7 +77,7 @@ module Arel end def project(*attributes) - attributes.all?(&:blank?) ? self : Projection.new(self, *attributes) + attributes.all?(&:blank?) ? self : Project.new(self, *attributes) end def alias @@ -97,12 +97,12 @@ module Arel end def group(*groupings) - groupings.all?(&:blank?) ? self : Grouping.new(self, *groupings) + groupings.all?(&:blank?) ? self : Group.new(self, *groupings) end module Writable def insert(record) - session.create Insertion.new(self, record); self + session.create Insert.new(self, record); self end def update(assignments) -- cgit v1.2.3