From fd40fbc1983a96587cc25729985191573a03e04c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 6 Jun 2008 03:54:16 -0700 Subject: Generate less garbage when expanding range bind variables in conditions --- activerecord/lib/active_record/base.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8dd07eb478..110902b590 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2064,13 +2064,18 @@ module ActiveRecord #:nodoc: end def expand_range_bind_variables(bind_vars) #:nodoc: - bind_vars.sum do |var| + expanded = [] + + bind_vars.each do |var| if var.is_a?(Range) - [var.first, var.last] + expanded << var.first + expanded << var.last else - [var] + expanded << var end end + + expanded end def quote_bound_value(value) #:nodoc: -- cgit v1.2.3 From 89ea7bee3609e513b21151eb4a7991b074fc0e8f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 7 Jun 2008 01:25:27 +0100 Subject: Simplify ActiveRecord::Base#update_attribute --- activerecord/lib/active_record/base.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 110902b590..450ea5cb33 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2252,12 +2252,12 @@ module ActiveRecord #:nodoc: end end - # Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records. - # Note: This method is overwritten by the Validation module that'll make sure that updates made with this method - # aren't subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid. + # Updates a single attribute and saves the record without going through the normal validation procedure. + # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method + # in Base is replaced with this when the validations module is mixed in, which it is by default. def update_attribute(name, value) send(name.to_s + '=', value) - save + save(false) end # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will -- cgit v1.2.3 From e6c1f46eb0fe637195bdf95647dd3aee72467580 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 11 Jun 2008 13:17:23 -0700 Subject: Silence scope resolution warnings --- activerecord/lib/active_record/base.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 450ea5cb33..1c16d5de03 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1903,10 +1903,12 @@ module ActiveRecord #:nodoc: # MyApp::Business::Account would appear as MyApp::Business::AccountSubclass. def compute_type(type_name) modularized_name = type_name_with_module(type_name) - begin - class_eval(modularized_name, __FILE__, __LINE__) - rescue NameError - class_eval(type_name, __FILE__, __LINE__) + silence_warnings do + begin + class_eval(modularized_name, __FILE__, __LINE__) + rescue NameError + class_eval(type_name, __FILE__, __LINE__) + end end end -- cgit v1.2.3