Class: Garden::Generators::ScaffoldGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Garden::Generators::ScaffoldGenerator
- Defined in:
- lib/generators/garden/scaffold/scaffold_generator.rb
Instance Method Summary collapse
- #ensure_locales ⇒ Object
- #generate_pundit_policy ⇒ Object
- #generate_scaffolding ⇒ Object
- #generate_talent_scout_search ⇒ Object
-
#initialize(raw_args, raw_opts, config) ⇒ ScaffoldGenerator
constructor
override
initialize
because it is the only way to reliably capture the raw input arguments in order to pass them on to ‘rails generate resource` (Thor neglects to provide an accessor, and ARGV is not populated during unit tests). - #inject_garden_variety_into_controller ⇒ Object
Constructor Details
#initialize(raw_args, raw_opts, config) ⇒ ScaffoldGenerator
override initialize
because it is the only way to reliably capture the raw input arguments in order to pass them on to ‘rails generate resource` (Thor neglects to provide an accessor, and ARGV is not populated during unit tests)
21 22 23 24 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 21 def initialize(raw_args, raw_opts, config) @argv = raw_args + raw_opts super end |
Instance Method Details
#ensure_locales ⇒ Object
26 27 28 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 26 def ensure_locales directory "../../install/templates/locales", "config/locales", skip: true end |
#generate_pundit_policy ⇒ Object
41 42 43 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 41 def generate_pundit_policy generate("pundit:policy", resource) end |
#generate_scaffolding ⇒ Object
30 31 32 33 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 30 def generate_scaffolding generate("resource", *@argv) generate("#{[:template_engine]}:scaffold", *@argv) end |
#generate_talent_scout_search ⇒ Object
45 46 47 48 49 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 45 def generate_talent_scout_search if defined?(::TalentScout) && .talent_scout? generate("talent_scout:search", resource) end end |
#inject_garden_variety_into_controller ⇒ Object
35 36 37 38 39 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 35 def inject_garden_variety_into_controller inject_into_class("app/controllers/#{resource.tableize}_controller.rb", "#{resource.tableize.camelize}Controller", " garden_variety\n") end |