Class: HelperGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::BasicHelper
Defined in:
lib/generators/helper/helper_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Rails::Generators::BasicHelper

#info

Class Method Details

.source_rootObject



6
7
8
# File 'lib/generators/helper/helper_generator.rb', line 6

def self.source_root
  @source_root ||= File.expand_path("../templates", __FILE__)
end

Instance Method Details

#add_helper_methodObject



10
11
12
13
14
15
16
17
# File 'lib/generators/helper/helper_generator.rb', line 10

def add_helper_method
  info "add_helper_method: #{helper_file_name}" 
  if File.exist?(helper_file_name)
    inject_into_file(helper_file_name, helper_method_code, :after => after_txt) if after_txt
  else
    say "#{helper_file_name} does not exist. Please create it first before you can add a helper method to it!", :red
  end
end