class SkinnyScaffoldGenerator
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/generators/skinny_scaffold_generator.rb, line 9 def initialize(*args) super end
Public Instance Methods
copy_controller_file()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 13 def copy_controller_file template 'controller.rb', controller_filename_with_path end
copy_view_files()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 25 def copy_view_files available_views.each do |view| template view_filename_with_extensions(view, :erb), File.join('app/views', controller_file_path, view_filename_with_extensions(view)) end end
create_view_folder()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 21 def create_view_folder empty_directory File.join('app/views', controller_file_path) end
handle_helper_file()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 17 def handle_helper_file behavior == :invoke ? do_copy_helper_file : dont_remove_helper_file end
Protected Instance Methods
available_views()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 34 def available_views %w{index _form new edit} end
controller_filename_with_path()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 46 def controller_filename_with_path File.join('app/controllers', "#{controller_name}_controller.rb") end
do_copy_helper_file()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 58 def do_copy_helper_file return if File.exists?(helper_filename_with_path) say_status 'NOTE >>>', 'Helper file will only be created once and will need to be removed manually!', :yellow copy_file 'helper.rb', helper_filename_with_path end
dont_remove_helper_file()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 64 def dont_remove_helper_file return unless File.exists?(helper_filename_with_path) say_status 'NOTE >>>', 'Helper file must be removed manually to prevent destruction of customizations!', :yellow end
format()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 38 def format :html end
handler()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 42 def handler :haml end
helper_filename_with_path()
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 54 def helper_filename_with_path 'app/helpers/skinny_scaffold_helper.rb' end
view_filename_with_extensions(name, local_handler = handler)
click to toggle source
# File lib/generators/skinny_scaffold_generator.rb, line 50 def view_filename_with_extensions(name, local_handler = handler) [name, format, local_handler].compact.join('.') end