aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/active_relation/relations.rb1
-rw-r--r--lib/active_relation/relations/relation.rb14
-rw-r--r--lib/active_relation/relations/rename.rb26
3 files changed, 6 insertions, 35 deletions
diff --git a/lib/active_relation/relations.rb b/lib/active_relation/relations.rb
index 240c20736e..9cede2a6d1 100644
--- a/lib/active_relation/relations.rb
+++ b/lib/active_relation/relations.rb
@@ -10,7 +10,6 @@ require 'active_relation/relations/selection'
require 'active_relation/relations/order'
require 'active_relation/relations/take'
require 'active_relation/relations/skip'
-require 'active_relation/relations/rename'
require 'active_relation/relations/deletion'
require 'active_relation/relations/insertion'
require 'active_relation/relations/update'
diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb
index f5f2809724..b62a5d9fb9 100644
--- a/lib/active_relation/relations/relation.rb
+++ b/lib/active_relation/relations/relation.rb
@@ -18,12 +18,14 @@ module ActiveRelation
include Enumerable
module Operations
- def join(other)
+ def join(other = nil)
case other
when String
Join.new(other, self)
when Relation
JoinOperation.new("INNER JOIN", self, other)
+ else
+ self
end
end
@@ -48,7 +50,7 @@ module ActiveRelation
attributes.all?(&:blank?) ? self : Projection.new(self, *attributes)
end
- def as(aliaz)
+ def as(aliaz = nil)
aliaz.blank?? self : Alias.new(self, aliaz)
end
@@ -56,18 +58,14 @@ module ActiveRelation
attributes.all?(&:blank?) ? self : Order.new(self, *attributes)
end
- def take(taken)
+ def take(taken = nil)
taken.blank?? self : Take.new(self, taken)
end
- def skip(skipped)
+ def skip(skipped = nil)
skipped.blank?? self : Skip.new(self, skipped)
end
- def rename(attribute, aliaz)
- Rename.new(self, attribute => aliaz)
- end
-
def aggregate(*expressions)
AggregateOperation.new(self, expressions)
end
diff --git a/lib/active_relation/relations/rename.rb b/lib/active_relation/relations/rename.rb
deleted file mode 100644
index 9ab07707a0..0000000000
--- a/lib/active_relation/relations/rename.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-module ActiveRelation
- class Rename < Compound
- attr_reader :attribute, :pseudonym
-
- def initialize(relation, pseudonyms)
- @attribute, @pseudonym = pseudonyms.shift
- @relation = pseudonyms.empty?? relation : Rename.new(relation, pseudonyms)
- end
-
- def ==(other)
- self.class == other.class and
- relation == other.relation and
- attribute == other.attribute and
- pseudonym == other.pseudonym
- end
-
- def attributes
- relation.attributes.collect(&method(:christen))
- end
-
- private
- def christen(attribute)
- (attribute =~ self.attribute ? attribute.as(pseudonym) : attribute).bind(self) rescue nil
- end
- end
-end \ No newline at end of file