diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2014-01-01 15:24:54 +0100 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2014-01-01 15:29:24 +0100 |
commit | afc98eadb892b735a9e40fbd2a9166f15822c569 (patch) | |
tree | 95b471fd5b29befe94edd7caff2d6737200fa9a7 /activesupport | |
parent | 97ddfb48dbab8d9410e473f3f6e7e2d189b97b4f (diff) | |
download | rails-afc98eadb892b735a9e40fbd2a9166f15822c569.tar.gz rails-afc98eadb892b735a9e40fbd2a9166f15822c569.tar.bz2 rails-afc98eadb892b735a9e40fbd2a9166f15822c569.zip |
Avoid raising a NameError on FreeBSD using Date
The Date object has a xmlschema method starting with Ruby 1.9 so we were
assuming that we could safely remove this method and redefine it later
but the call to remove_method throws a NameError on FreeBSD so we should
rely on remove_possible_method instead.
This call is actually needed to avoid warnings when running the test
suite.
Fixes #11723
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/conversions.rb | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 338e9a1e13..b1a6ac30d3 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,8 @@ +* Use `remove_possible_method` instead of `remove_method` to avoid + a `NameError` to be thrown on FreeBSD with the `Date` object. + + *Rafael Mendonça França*, *Robin Dupret* + * `blank?` and `present?` commit to return singletons. *Xavier Noria*, *Pavel Pravosud* diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb index 09504a4d9c..df419a6e63 100644 --- a/activesupport/lib/active_support/core_ext/date/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date/conversions.rb @@ -1,6 +1,7 @@ require 'date' require 'active_support/inflector/methods' require 'active_support/core_ext/date/zones' +require 'active_support/core_ext/module/remove_method' class Date DATE_FORMATS = { @@ -19,8 +20,10 @@ class Date # Ruby 1.9 has Date#to_time which converts to localtime only. remove_method :to_time - # Ruby 1.9 has Date#xmlschema which converts to a string without the time component. - remove_method :xmlschema + # Ruby 1.9 has Date#xmlschema which converts to a string without the time + # component. This removal may generate an issue on FreeBSD, that's why we + # need to use remove_possible_method here + remove_possible_method :xmlschema # Convert to a formatted string. See DATE_FORMATS for predefined formats. # |