aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/utilities/compound.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/relations/utilities/compound.rb')
-rw-r--r--lib/arel/relations/utilities/compound.rb26
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/arel/relations/utilities/compound.rb b/lib/arel/relations/utilities/compound.rb
index a77099e0de..23a55d4b5b 100644
--- a/lib/arel/relations/utilities/compound.rb
+++ b/lib/arel/relations/utilities/compound.rb
@@ -2,25 +2,17 @@ module Arel
class Compound < Relation
attr_reader :relation
hash_on :relation
- delegate :joins, :wheres, :join?, :inserts, :taken,
- :skipped, :name, :aggregation?, :column_for,
- :engine, :table, :table_sql,
+ delegate :joins, :join?, :inserts, :taken, :skipped, :name, :aggregation?,
+ :column_for, :engine, :table, :table_sql,
:to => :relation
- def attributes
- @attributes ||= relation.attributes.collect { |a| a.bind(self) }
- end
-
- def wheres
- @wheres ||= relation.wheres.collect { |w| w.bind(self) }
- end
-
- def groupings
- @groupings ||= relation.groupings.collect { |g| g.bind(self) }
- end
-
- def orders
- @orders ||= relation.orders.collect { |o| o.bind(self) }
+ [:attributes, :wheres, :groupings, :orders].each do |operation_name|
+ operation = <<-OPERATION
+ def #{operation_name}
+ @#{operation_name} ||= relation.#{operation_name}.collect { |o| o.bind(self) }
+ end
+ OPERATION
+ class_eval operation, __FILE__, __LINE__
end
end
end \ No newline at end of file