Jedrin
2012-Apr-20  19:40 UTC
trying to work out what is going on with monkey patch of String
Somewhere in all of the ruby code that gets included into this app I
am working on, there is something that defined String so that the
following is a valid statement
puts "contact us at " +
"info-GXcTff7tL0M@public.gmane.org"[] + " and say hello"
 The app that runs, is able to include that stuff and Ruby doesn''t
complain. When I try to write a test module and
include some of the code, ruby complains beuse my load paths or some
part of the configuration is different. I am not really sure.
 If I monkey patch string like below, it seems to stop the errors, but
I am not sure if it could be causing other problems.
class String
  def [](x=nil,b=nil)
    self
  end
end
I am on windows, but I am using cygwin. I did something like what''s
below, but did not find where [] might be defined:
 find . -name "*.rb" -exec grep -A 15 "class String" {} \;
-print > /
cygdrive/c/tmp/str-patch.txt
Any other ideas to figure this out ? How can I tell inside irb or
something what the code is for "info-GXcTff7tL0M@public.gmane.org"[]
or where it is defined ?
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2012-Apr-22  08:34 UTC
Re: trying to work out what is going on with monkey patch of String
On 20 April 2012 20:40, Jedrin <jrubiando-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Somewhere in all of the ruby code that gets included into this app I > am working on, there is something that defined String so that the > following is a valid statement > > puts "contact us at " + "info-GXcTff7tL0M@public.gmane.org"[] + " and say hello" > > > The app that runs, is able to include that stuff and Ruby doesn''t > complain. When I try to write a test module and > include some of the code, ruby complains beuse my load paths or some > part of the configuration is different. I am not really sure. > > If I monkey patch string like below, it seems to stop the errors, but > I am not sure if it could be causing other problems. > > class String > def [](x=nil,b=nil) > self > end > end > > I am on windows, but I am using cygwin. I did something like what''s > below, but did not find where [] might be defined: > > find . -name "*.rb" -exec grep -A 15 "class String" {} \; -print > / > cygdrive/c/tmp/str-patch.txt > > > Any other ideas to figure this out ? How can I tell inside irb or > something what the code is for "info-GXcTff7tL0M@public.gmane.org"[] > or where it is defined ?You could use ruby-debug (assuming that is available on Windows, I don''t know) and step into "string"[] to see where it is defined. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.