Sha256: d9f87cfaecb839809b75d182fe7ca6c737a40af5b2599000e2b4ea210bc66327
Contents?: true
Size: 762 Bytes
Versions: 5
Compression:
Stored size: 762 Bytes
Contents
class HelperGenerator < Rails::Generators::NamedBase desc "Adds method 'help_me' to a Helper" def self.source_root @source_root ||= File.expand_path("../templates", __FILE__) end def add_helper_method 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 protected def after_txt "#{class_name}Helper" end def helper_file_name File.join(Rails.root, "app/helpers/#{file_name}_helper.rb") end def helper_method_code %Q{ def help_me "Help me please!" end } end end
Version data entries
5 entries across 5 versions & 1 rubygems