Class: Garden::Generators::ScaffoldGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Garden::Generators::ScaffoldGenerator
- Includes:
- OptimizedGenerateAction
- 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
initializebecause 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
Methods included from OptimizedGenerateAction
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)
25 26 27 28 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 25 def initialize(raw_args, raw_opts, config) @argv = raw_args + raw_opts super end |
Instance Method Details
#ensure_locales ⇒ Object
30 31 32 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 30 def ensure_locales directory "../../install/templates/locales", "config/locales", skip: true end |
#generate_pundit_policy ⇒ Object
45 46 47 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 45 def generate_pundit_policy generate("pundit:policy", resource) end |
#generate_scaffolding ⇒ Object
34 35 36 37 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 34 def generate_scaffolding generate("resource", *@argv) generate("#{[:template_engine]}:scaffold", *@argv) end |
#generate_talent_scout_search ⇒ Object
49 50 51 52 53 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 49 def generate_talent_scout_search if defined?(::TalentScout) && .talent_scout? generate("talent_scout:search", resource) end end |
#inject_garden_variety_into_controller ⇒ Object
39 40 41 42 43 |
# File 'lib/generators/garden/scaffold/scaffold_generator.rb', line 39 def inject_garden_variety_into_controller inject_into_class("app/controllers/#{resource.tableize}_controller.rb", "#{resource.tableize.camelize}Controller", " garden_variety\n") end |