From 39076f34ce75240028844681f83c488ef606ea04 Mon Sep 17 00:00:00 2001 From: Anatoliy Lysenko Date: Thu, 7 Apr 2011 15:41:01 +0300 Subject: [PATCH 3/3] Refactoring ActiveRecord::Relation. Delegate #inspect and #as_json to #to_a. --- activerecord/lib/active_record/relation.rb | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 75269c8..5de8bb0 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -11,7 +11,7 @@ module ActiveRecord include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches # These are explicitly delegated to improve performance (avoids method_missing) - delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to => :to_a + delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :inspect, :as_json, :to => :to_a delegate :table_name, :quoted_table_name, :primary_key, :quoted_primary_key, :to => :klass attr_reader :table, :klass, :loaded @@ -110,10 +110,6 @@ module ActiveRecord @records end - def as_json(options = nil) #:nodoc: - to_a.as_json(options) - end - # Returns size of the records. def size loaded? ? @records.length : count @@ -401,10 +397,6 @@ module ActiveRecord end end - def inspect - to_a.inspect - end - protected def method_missing(method, *args, &block) -- 1.7.0.4