Class: LayoutHelperGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- LayoutHelperGenerator
- Defined in:
- lib/generators/layout_helper/layout_helper_generator.rb
Instance Method Summary collapse
- #add_description_method ⇒ Object private
- #add_title_method ⇒ Object private
- #copy_template_file ⇒ Object
- #file_path ⇒ Object private
Instance Method Details
#add_description_method ⇒ Object (private)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/generators/layout_helper/layout_helper_generator.rb', line 41 def add_description_method inject_into_file(file_path, after: "module LayoutHelper\n") do " \ndef description(value = nil)\n if value\n @description = value\n else\n @description.to_s\n end\nend\n RUBY\n end\nend\n" |
#add_title_method ⇒ Object (private)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/layout_helper/layout_helper_generator.rb', line 26 def add_title_method inject_into_file(file_path, after: "module LayoutHelper\n") do " \ndef title(value = nil)\n if value\n @title = value\n else\n @title.to_s\n end\nend \n RUBY\n end\nend\n" |
#copy_template_file ⇒ Object
13 14 15 16 17 |
# File 'lib/generators/layout_helper/layout_helper_generator.rb', line 13 def copy_template_file generate "helper", "Layout" add_title_method add_description_method end |
#file_path ⇒ Object (private)
22 23 24 |
# File 'lib/generators/layout_helper/layout_helper_generator.rb', line 22 def file_path Rails.root.join('app', 'helpers', "layout_helper.rb") end |