Class: Pu::Res::ConnGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Pu::Res::ConnGenerator
- Defined in:
- lib/generators/pu/res/conn/conn_generator.rb
Instance Method Summary collapse
-
#start ⇒ Object
argument :name.
Methods included from PlutoniumGenerators::Concerns::ResourceSelector
Methods included from PlutoniumGenerators::Generator
Methods included from PlutoniumGenerators::Concerns::Logger
#debug, #error, #exception, #info, #success, #warn
Methods included from PlutoniumGenerators::Concerns::Config
Instance Method Details
#start ⇒ Object
argument :name
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/pu/res/conn/conn_generator.rb', line 20 def start selected_resources = resources_selection @app_namespace = portal_option(:dest, prompt: "Select destination portal").camelize selected_resources.each do |resource| @resource_class = resource if app_namespace == "MainApp" insert_into_file "config/routes.rb", indent("register_resource ::#{resource}\n", 2), after: /.*Rails\.application\.routes\.draw do.*\n/ else unless expected_parent_policy template "app/policies/resource_policy.rb", "packages/#{package_namespace}/app/policies/#{package_namespace}/#{resource.underscore}_policy.rb" end unless expected_parent_definition template "app/definitions/resource_definition.rb", "packages/#{package_namespace}/app/definitions/#{package_namespace}/#{resource.underscore}_definition.rb" end template "app/controllers/resource_controller.rb", "packages/#{package_namespace}/app/controllers/#{package_namespace}/#{resource.pluralize.underscore}_controller.rb" insert_into_file "packages/#{package_namespace}/config/routes.rb", indent("register_resource ::#{resource}\n", 2), before: /.*# register resources above.*/ end end rescue => e exception "#{self.class} failed:", e end |