From a5587efc1903fd27d4b179753aa6e139445ad18c Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:15:55 -0700 Subject: Remove some 1.9 warnings (resulting in some fixed bugs). Remaining AM warnings are in dependencies. --- .../lib/active_support/core_ext/class/attribute.rb | 3 +++ activesupport/lib/active_support/core_ext/module.rb | 3 ++- .../lib/active_support/core_ext/module/method_names.rb | 14 ++++++++++++++ .../lib/active_support/core_ext/string/inflections.rb | 2 -- .../lib/active_support/core_ext/string/output_safety.rb | 6 ++++-- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 activesupport/lib/active_support/core_ext/module/method_names.rb (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index c18905b369..9631a7d242 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/object/singleton_class' require 'active_support/core_ext/module/delegation' +require 'active_support/core_ext/module/remove_method' class Class # Declare a class-level attribute whose value is inheritable and @@ -45,12 +46,14 @@ class Class s.send(:define_method, attr) { } s.send(:define_method, :"#{attr}?") { !!send(attr) } s.send(:define_method, :"#{attr}=") do |value| + singleton_class.remove_possible_method(attr) singleton_class.send(:define_method, attr) { value } end define_method(attr) { self.class.send(attr) } define_method(:"#{attr}?") { !!send(attr) } define_method(:"#{attr}=") do |value| + singleton_class.remove_possible_method(attr) singleton_class.send(:define_method, attr) { value } end if instance_writer end diff --git a/activesupport/lib/active_support/core_ext/module.rb b/activesupport/lib/active_support/core_ext/module.rb index e74bbde344..f59fcd123c 100644 --- a/activesupport/lib/active_support/core_ext/module.rb +++ b/activesupport/lib/active_support/core_ext/module.rb @@ -8,4 +8,5 @@ require 'active_support/core_ext/module/attr_accessor_with_default' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/synchronization' require 'active_support/core_ext/module/deprecation' -require 'active_support/core_ext/module/remove_method' \ No newline at end of file +require 'active_support/core_ext/module/remove_method' +require 'active_support/core_ext/module/method_names' \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/module/method_names.rb b/activesupport/lib/active_support/core_ext/module/method_names.rb new file mode 100644 index 0000000000..2eb40a83ab --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/method_names.rb @@ -0,0 +1,14 @@ +class Module + if instance_methods[0].is_a?(Symbol) + def instance_method_names(*args) + instance_methods(*args).map(&:to_s) + end + + def method_names(*args) + methods(*args).map(&:to_s) + end + else + alias_method :instance_method_names, :instance_methods + alias_method :method_names, :methods + end +end \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index fbb7b79fc6..48b028bb64 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -1,5 +1,3 @@ -require 'active_support/inflector' - # String inflections define new methods on the String class to transform names for different purposes. # For instance, you can figure out the name of a database from the name of a class. # diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 9a7c520e75..5babc297c1 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -23,12 +23,14 @@ class ERB end end - undef :h + remove_method(:h) alias h html_escape - module_function :html_escape module_function :h + singleton_class.send(:remove_method, :html_escape) + module_function :html_escape + # A utility method for escaping HTML entities in JSON strings. # This method is also aliased as j. # -- cgit v1.2.3