TuftsUniversity/whowas

View on GitHub
lib/generators/whowas/search_method_generator.rb

Summary

Maintainability
A
20 mins
Test Coverage
module Whowas
  class SearchMethodGenerator < Rails::Generators::NamedBase
    source_root File.expand_path("../templates", __FILE__)
    
    def create
      copy_file "search_method.rb", "app/whowas/search_methods/#{file_name}.rb"
    end
    
    def rename_class
      gsub_file "app/whowas/search_methods/#{file_name}.rb", /MySearchMethod/, name.camelize
    end
  end
end