The following code works in Ruby 1.8.7 but not in 1.9.2, instead, I get
the error:
NoMethodError: undefined method `old_encode64’ for Base64:Module
Can someone please shed some light on this.
Thanks in advance,
Tron
module Base64
alias :old_encode64 :encode64
module_function # this seems to be necessary – get a “wrong number of
arguments (2 for 1)” without it this line.
def encode64(bin,options={})
if (options[:no_line_break] == true)
old_encode64(bin).gsub(/\n/, ‘’)
else
old_encode64(bin)
end
end
end
Thank you for your reply. However, your suggestion resulted in
SystemStackError: stack level too deep
I’m guessing that it is not working in 1.9.2 because Base64 is no longer
included with 1.9 and there is something odd going on with the
ActiveSupport’s version of it.
I ended up not using and just reimplemented the base64 encode as
[bin].pack(“m”)
Tron
Michael M. wrote:
On 8/29/2010 8:04 PM, Tron Fu wrote:
Thank you for your reply. However, your suggestion resulted in
SystemStackError: stack level too deep
I’m guessing that it is not working in 1.9.2 because Base64 is no longer
included with 1.9 and there is something odd going on with the
ActiveSupport’s version of it.
Tron
As far as I can tell, 1.9.2 ships with Base64.
I suspect you’re having trouble because of Base64’s use of
module_function. This creates copies of the original methods, so it
will be difficult to overload like this.
Thank you for your reply. However, your suggestion resulted in
SystemStackError: stack level too deep
I’m guessing that it is not working in 1.9.2 because Base64 is no longer
included with 1.9 and there is something odd going on with the
ActiveSupport’s version of it.
Tron
As far as I can tell, 1.9.2 ships with Base64.
I suspect you’re having trouble because of Base64’s use of
module_function. This creates copies of the original methods, so it
will be difficult to overload like this.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.