From 8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Mon, 22 Dec 2014 20:14:14 -0800 Subject: fix ruby 2.2 warning: circular argument reference --- activesupport/lib/active_support/values/time_zone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index f935180036..618c93125c 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=now()) parts = Date._parse(str, false) return if parts.empty? -- cgit v1.2.3 From 047b2a9fcf893287a01de621dc40d6b29e701747 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 9 Jan 2014 14:12:05 -0800 Subject: Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314 --- .../lib/active_support/core_ext/date_time/calculations.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index 0481bd2195..0ff36eeb6d 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -138,6 +138,12 @@ class DateTime # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime def <=>(other) - super other.kind_of?(Infinity) ? other : other.to_datetime + if other.kind_of?(Infinity) + super + elsif other.respond_to? :to_datetime + super other.to_datetime + else + nil + end end end -- cgit v1.2.3 From 98dbc5e3cc248859b8c881dbcd228f8ad0743f21 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Jan 2015 21:04:03 -0800 Subject: fix yaml compat on ruby 2.2 --- activesupport/lib/active_support/core_ext/big_decimal/conversions.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb index 391bdc925d..d2039fcc1e 100644 --- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb +++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb @@ -16,7 +16,9 @@ class BigDecimal # # Note that reconstituting YAML floats to native floats may lose precision. def to_yaml(opts = {}) - return super if defined?(YAML::ENGINE) && !YAML::ENGINE.syck? + return super if + (defined?(YAML::ENGINE) && !YAML::ENGINE.syck?) || + (defined?(Psych) && YAML == Psych) YAML.quick_emit(nil, opts) do |out| string = to_s -- cgit v1.2.3 From 2f558088acb2ab65ed4dcd87a8ef42d1b26a8035 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Mon, 14 Oct 2013 22:40:21 +0530 Subject: Fix `singleton_class?` Due to changes from http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39628 current `singleton_class?` implementation fails. Changed based on reference from http://bugs.ruby-lang.org/issues/7609 Conflicts: activesupport/lib/active_support/core_ext/class/attribute.rb --- activesupport/lib/active_support/core_ext/class/attribute.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index cd7877fce4..14adc426d8 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -109,7 +109,9 @@ class Class end private - def singleton_class? - ancestors.first != self - end + unless respond_to?(:singleton_class?) + def singleton_class? + ancestors.first != self + end + end end -- cgit v1.2.3 From 3a30b12c774dfaa72acfe520e823374131631ea9 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Jan 2015 22:03:42 -0800 Subject: use self.method syntax to resolve circular argument issues --- activesupport/lib/active_support/values/time_zone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') 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? -- cgit v1.2.3