aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 19f91f4278..decde50427 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -5,9 +5,10 @@ module ActiveRecord
MULTI_VALUE_METHODS = [:select, :group, :order, :joins, :where, :having]
SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :create_with, :from]
- include FinderMethods, CalculationMethods, SpawnMethods, QueryMethods
+ include FinderMethods, Calculations, SpawnMethods, QueryMethods
delegate :length, :collect, :map, :each, :all?, :include?, :to => :to_a
+ delegate :insert, :update, :to => :arel
attr_reader :table, :klass
@@ -59,8 +60,6 @@ module ActiveRecord
@records
end
- alias all to_a
-
def size
loaded? ? @records.length : count
end
@@ -139,10 +138,10 @@ module ActiveRecord
protected
def method_missing(method, *args, &block)
- if arel.respond_to?(method)
- arel.send(method, *args, &block)
- elsif Array.method_defined?(method)
+ if Array.method_defined?(method)
to_a.send(method, *args, &block)
+ elsif arel.respond_to?(method)
+ arel.send(method, *args, &block)
elsif match = DynamicFinderMatch.match(method)
attributes = match.attribute_names
super unless @klass.send(:all_attributes_exists?, attributes)
@@ -163,10 +162,6 @@ module ActiveRecord
@klass.send(:with_scope, :create => scope_for_create, :find => {}) { yield }
end
- def where_clause(join_string = " AND ")
- arel.send(:where_clauses).join(join_string)
- end
-
def references_eager_loaded_tables?
joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.uniq
(tables_in_string(to_sql) - joined_tables).any?