T
Tim Pease
Is there a way to disable specific warnings from within a Ruby program
(not from the command line)?
The warnings are coming from some meta-programming code that is
redefining instance methods on the fly based on user input. So maybe a
better question would be, is there a way to redefine methods without
causing Ruby to spew out a warning each time the method is redefined.
This is the result of using Hoe (thanks Ryan, Eric, and other sun
deprived Rubyists) to run my unit tests. Hoe adds the -w flag to the
Ruby interpreter when it runs tests. This is a good thing as it found
several minor flaws in my code. But redefining methods is at the heart
of what I'm trying to do.
Example:
class Pattern
def self.create_date_format_methods( pf )
module_eval <<-CODE
def pf.format_date
Time.now.strftime "#{pf.date_pattern}"
end
CODE
end
end
When running unit tests with the -w flag ...
(eval):1: warning: redefine format_date
Any thoughts on how to suppress the warning and/or change my
meta-programming so the warning does not show up?
Blessings,
TwP
(not from the command line)?
The warnings are coming from some meta-programming code that is
redefining instance methods on the fly based on user input. So maybe a
better question would be, is there a way to redefine methods without
causing Ruby to spew out a warning each time the method is redefined.
This is the result of using Hoe (thanks Ryan, Eric, and other sun
deprived Rubyists) to run my unit tests. Hoe adds the -w flag to the
Ruby interpreter when it runs tests. This is a good thing as it found
several minor flaws in my code. But redefining methods is at the heart
of what I'm trying to do.
Example:
class Pattern
def self.create_date_format_methods( pf )
module_eval <<-CODE
def pf.format_date
Time.now.strftime "#{pf.date_pattern}"
end
CODE
end
end
When running unit tests with the -w flag ...
(eval):1: warning: redefine format_date
Any thoughts on how to suppress the warning and/or change my
meta-programming so the warning does not show up?
Blessings,
TwP