diff options
Diffstat (limited to 'lib/active_relation/relations/compound.rb')
-rw-r--r-- | lib/active_relation/relations/compound.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/active_relation/relations/compound.rb b/lib/active_relation/relations/compound.rb index 332147523e..7c4a7e707b 100644 --- a/lib/active_relation/relations/compound.rb +++ b/lib/active_relation/relations/compound.rb @@ -1,8 +1,25 @@ module ActiveRelation class Compound < Relation attr_reader :relation - delegate :projections, :attributes, :attribute, :joins, :selects, :orders, :groupings, :table_sql, :inserts, :limit, + delegate :joins, :selects, :orders, :groupings, :table_sql, :inserts, :limit, :offset, :name, :alias, :aggregation?, :to => :relation + + def attributes + relation.attributes.collect { |a| a.substitute(self) } + end + + protected + def attribute_for_name(name) + (a = relation[name]) && a.substitute(self) + end + + def attribute_for_attribute(attribute) + attribute.relation == self ? attribute : (a = relation[attribute]) && a.substitute(self) + end + + def attribute_for_expression(expression) + expression.relation == self ? expression : (a = relation[expression]) && a.substitute(self) + end end end
\ No newline at end of file |