diff options
author | Aman Gupta <aman@tmm1.net> | 2015-01-02 22:03:42 -0800 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2015-01-02 22:03:42 -0800 |
commit | 3a30b12c774dfaa72acfe520e823374131631ea9 (patch) | |
tree | b1d1c4b135c4064e5d44b9d7b0a9d7d862b0d9e9 | |
parent | 2f558088acb2ab65ed4dcd87a8ef42d1b26a8035 (diff) | |
download | rails-3a30b12c774dfaa72acfe520e823374131631ea9.tar.gz rails-3a30b12c774dfaa72acfe520e823374131631ea9.tar.bz2 rails-3a30b12c774dfaa72acfe520e823374131631ea9.zip |
use self.method syntax to resolve circular argument issues
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 8 | ||||
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index c9bca68904..4ea39681e2 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -50,15 +50,15 @@ module ActiveRecord [options[:limit], count].compact.min end - def has_cached_counter?(reflection = reflection()) + def has_cached_counter?(reflection = self.reflection) owner.attribute_present?(cached_counter_attribute_name(reflection)) end - def cached_counter_attribute_name(reflection = reflection()) + def cached_counter_attribute_name(reflection = self.reflection) "#{reflection.name}_count" end - def update_counter(difference, reflection = reflection()) + def update_counter(difference, reflection = self.reflection) if has_cached_counter?(reflection) counter = cached_counter_attribute_name(reflection) owner.class.update_counters(owner.id, counter => difference) @@ -77,7 +77,7 @@ module ActiveRecord # it will be decremented twice. # # Hence this method. - def inverse_updates_counter_cache?(reflection = reflection()) + def inverse_updates_counter_cache?(reflection = self.reflection) counter_name = cached_counter_attribute_name(reflection) reflection.klass.reflect_on_all_associations(:belongs_to).any? { |inverse_reflection| inverse_reflection.counter_cache_column == counter_name diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 618c93125c..01aea0984b 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -267,7 +267,7 @@ module ActiveSupport # # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 - def parse(str, now=now()) + def parse(str, now=self.now) parts = Date._parse(str, false) return if parts.empty? |