Class: Padrino::Generators::BsAdminPage
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Padrino::Generators::BsAdminPage
- Includes:
- Actions, Admin::Actions, Thor::Actions
- Defined in:
- lib/bootstrap-on/bs_admin_page.rb
Overview
Defines the generator for creating a new admin page.
Instance Attribute Summary collapse
-
#default_orm ⇒ Object
Returns the value of attribute default_orm.
Class Method Summary collapse
-
.banner ⇒ Object
Defines the “banner” text for the CLI.
-
.source_root ⇒ Object
Define the source template root.
Instance Method Summary collapse
-
#create_controller ⇒ Object
Create controller for admin.
Instance Attribute Details
#default_orm ⇒ Object
Returns the value of attribute default_orm.
7 8 9 |
# File 'lib/bootstrap-on/bs_admin_page.rb', line 7 def default_orm @default_orm end |
Class Method Details
.banner ⇒ Object
Defines the “banner” text for the CLI.
15 |
# File 'lib/bootstrap-on/bs_admin_page.rb', line 15 def self.; "padrino g bs_admin_page [model]"; end |
.source_root ⇒ Object
Define the source template root
13 |
# File 'lib/bootstrap-on/bs_admin_page.rb', line 13 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#create_controller ⇒ Object
Create controller for admin
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bootstrap-on/bs_admin_page.rb', line 33 def create_controller self.destination_root = [:root] if in_app_root? models.each do |model| @orm = default_orm || Padrino::Admin::Generators::Orm.new(model, adapter) self.behavior = :revoke if [:destroy] empty_directory destination_root("/admin/views/#{@orm.name_plural}") template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb") template "templates/#{ext}/page/_form.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.#{ext}") template "templates/#{ext}/page/edit.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/edit.#{ext}") template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}") template "templates/#{ext}/page/new.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/new.#{ext}") [:destroy] ? remove_project_module(@orm.name_plural) : add_project_module(@orm.name_plural) end else say "You are not at the root of a Padrino application! (config/boot.rb not found)" end end |