I have a ruby script lib/tasks/material_parser_helper.rb
and a module lib/common_parser_methods.rb
How could I extends all the module methods into 'material_parser_helper.rb'
Therefore, I can call the clean_key
in any methods of MaterialParserHelper
If I tried to extend CommonParserMethods after the class,
I will got the error NameError: uninitialized constant SummaryProjection::CommonMethods
class MaterialParserHelper
extend CommonParserMethods
def test
clean_key("jckdj")
end
end
common_parser_methods.rb
module CommonParserMethods
def clean_key(key)
return key.strip.squish.gsub(/\s/, '_').gsub('-', '_').downcase
end
end
Application.rb
config.autoload_paths += %W(#{config.root}/lib/ #{config.root}/lib/common_parser_methods.rb #{config.root}/lib/tasks)