Class: Blade::Setting::ControllerTemplate::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blade::Setting::ControllerTemplate::InstallGenerator
- Defined in:
- lib/blade/setting/controller_template.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_gem(gem_name) ⇒ Object
- #add_routes(args, namespace) ⇒ Object
- #create_view_file(path, content) ⇒ Object
Class Method Details
.controller_tmp(model_class, name, namespace) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/blade/setting/controller_template.rb', line 29 def controller_tmp(model_class,name, namespace) model = model_class.name arg1 = name args = arg1.pluralize prefix = namespace.classify template = <<File class #{prefix}::#{model.pluralize}Controller < ApplicationController def index @response, @#{args} = #{model}Service.query_by_params params end def create @response, @#{arg1} = #{model}Service.create_by_params params end def update @response, @#{arg1} = #{model}Service.update_by_params params end def destroy @response = #{model}Service.delete_by_params params end end File end |
Instance Method Details
#add_gem(gem_name) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/blade/setting/controller_template.rb', line 21 def add_gem(gem_name) gem gem_name Bundler.with_clean_env do run "bundle install" end end |
#add_routes(args, namespace) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/blade/setting/controller_template.rb', line 13 def add_routes(args,namespace) route(" namespace :#{namespace} do resources :#{args} end ") end |
#create_view_file(path, content) ⇒ Object
9 10 11 |
# File 'lib/blade/setting/controller_template.rb', line 9 def create_view_file(path, content) create_file path, content end |