mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Fixed an issue with classes that define their own #send method (ex: Socket); fixed compatibility issue with Liquid gem
This commit is contained in:
parent
b2ce17dae6
commit
2562c2b787
6 changed files with 24 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
0.3.2 (unreleased)
|
||||
- Fixed an issue with classes that define their own #send method (ex: Socket)
|
||||
- Fixed compatibility issue with Liquid gem that defines Module#liquid_methods
|
||||
- Fixed hash spec for Ruby < 1.9 where order of hash keys is not guaranteed
|
||||
|
||||
0.3.1 RubyConf X edition
|
||||
- Fixed Ruby 1.8.6 compatibility issues (thanks, Tim!)
|
||||
- Fixed stack overflow issue with Rails 2.3.x console
|
||||
|
|
|
@ -16,7 +16,7 @@ class Array #:nodoc:
|
|||
[ :-, :& ].each do |operator|
|
||||
alias :"original_#{operator.object_id}" :"#{operator}"
|
||||
define_method operator do |*args|
|
||||
arr = self.send(:"original_#{operator.object_id}", *args)
|
||||
arr = self.__send__(:"original_#{operator.object_id}", *args)
|
||||
if self.instance_variable_defined?('@__awesome_methods__')
|
||||
arr.instance_variable_set('@__awesome_methods__', self.instance_variable_get('@__awesome_methods__'))
|
||||
arr.sort!
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
||||
#------------------------------------------------------------------------------
|
||||
class Class #:nodoc:
|
||||
methods.grep(/instance_methods$/) do |name|
|
||||
# Remaining public/private etc. '_methods' are handled in core_ext/object.rb.
|
||||
%w(instance_methods private_instance_methods protected_instance_methods public_instance_methods).each do |name|
|
||||
alias :"original_#{name}" :"#{name}"
|
||||
|
||||
define_method name do |*args|
|
||||
methods = self.send(:"original_#{name}", *args)
|
||||
methods = self.__send__(:"original_#{name}", *args)
|
||||
methods.instance_variable_set('@__awesome_methods__', self) # Evil?!
|
||||
methods.sort!
|
||||
end
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
||||
#------------------------------------------------------------------------------
|
||||
class Object #:nodoc:
|
||||
methods.grep(/methods$/) do |name|
|
||||
next if name.to_s.include? 'instance' # Instance methods are trapped in Class.
|
||||
|
||||
# Remaining instance '_methods' are handled in core_ext/class.rb.
|
||||
%w(methods private_methods protected_methods public_methods singleton_methods).each do |name|
|
||||
alias :"original_#{name}" :"#{name}"
|
||||
|
||||
define_method name do |*args|
|
||||
methods = self.send(:"original_#{name}", *args)
|
||||
methods = self.__send__(:"original_#{name}", *args)
|
||||
methods.instance_variable_set('@__awesome_methods__', self) # Evil?!
|
||||
methods.sort!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
0
lib/ap/core_ext/string.rb
Executable file → Normal file
0
lib/ap/core_ext/string.rb
Executable file → Normal file
|
@ -514,5 +514,14 @@ EOS
|
|||
my = My.new('/tmp')
|
||||
my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
|
||||
end
|
||||
|
||||
it "should handle a class that defines its own #send method" do
|
||||
class My
|
||||
def send(arg1, arg2, arg3); end
|
||||
end
|
||||
|
||||
my = My.new
|
||||
my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue