Ruby 2.0:define_method in top level
define_method can be used at the top level in Ruby 2.0; it doesn't have to
be inside a class or module.
Dir["config/*.yml"].each do |path|
%r{config/(?<name>.*)\.yml\z} =~ path
define_method(:"#{name}_config") {YAML.load_file(path)}
end
But as i know define_method is a method of Module, and main object did not
have such method in Ruby 1.9.
How Ruby 2.0 implement this?
No comments:
Post a Comment