aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/primitives/attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_relation/primitives/attribute.rb')
-rw-r--r--lib/active_relation/primitives/attribute.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb
index 90bbe8012b..eb167b1a66 100644
--- a/lib/active_relation/primitives/attribute.rb
+++ b/lib/active_relation/primitives/attribute.rb
@@ -6,18 +6,25 @@ module ActiveRelation
@relation, @name, @alias = relation, name, aliaz
end
- def as(aliaz = nil)
- Attribute.new(relation, name, aliaz)
- end
+ module Transformations
+ def as(aliaz = nil)
+ Attribute.new(relation, name, aliaz)
+ end
+
+ def substitute(new_relation)
+ Attribute.new(new_relation, name, @alias)
+ end
+ def qualify
+ self.as(qualified_name)
+ end
+ end
+ include Transformations
+
def qualified_name
"#{relation.name}.#{name}"
end
- def qualify
- self.as(qualified_name)
- end
-
def ==(other)
relation == other.relation and name == other.name and @alias == other.alias
end