Kernel on Ruby 1.9.2

Now it seems like Kernel it is not working the same way
I had this code in 1.8.7

module Kernel
private
def method_name
caller[0] =~ /`([^’]*)’/ and $1
end
end

and now it is giving me this error when calling method_name
NoMethodError: private method `method_name’ called for
#MyTest:0x269e260

http://apidock.com/ruby is good for tracking down this stuff. You can
search for a method, then select a Ruby version number to see where it
exists and where it doesn’t. Deprecated 1.8.7 methods’ descriptions
also usually refer you to a 1.9.x equivalent, if one exists.

On Thu, Oct 27, 2011 at 9:19 PM, Mario R. [email protected] wrote:

and now it is giving me this error when calling method_name
NoMethodError: private method `method_name’ called for
#MyTest:0x269e260

Can you show the calling code?

Kind regards

robert

I solved this by using it as public
Also another way is to use the variable @name

Thanks for the help

Robert K. wrote in post #1028993:

On Thu, Oct 27, 2011 at 9:19 PM, Mario R. [email protected] wrote:

and now it is giving me this error when calling method_name
NoMethodError: private method `method_name’ called for
#MyTest:0x269e260

Can you show the calling code?

Kind regards

robert

On Mon, Oct 31, 2011 at 3:56 PM, Mario R. [email protected] wrote:

I solved this by using it as public

That is not necessary, since your error was most likely that you
invoked the method with an explicit receiver.

Also another way is to use the variable @name

For what?

Kind regards

robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs