Module: Padrino::Generators::Admin::Actions
- Included in:
- Padrino::Generators::AdminApp, Padrino::Generators::AdminPage
- Defined in:
- padrino-admin/lib/padrino-admin/generators/actions.rb
Overview
Important tasks for setting up or configuring the admin application.
Instance Method Summary collapse
-
#add_project_module(controller) ⇒ Object
Add access_control permission in our app.rb.
-
#ext ⇒ Object
Tell us which rendering engine you are using.
-
#fetch_app_name(app = 'app') ⇒ String
Returns the app_name for the application at root.
-
#orm ⇒ Object
(also: #adapter)
Tell us which orm we are using.
-
#remove_project_module(controller) ⇒ Object
Remove from access_control permissions.
-
#supported_ext ⇒ Object
Tell us for now which rendering engine we support.
-
#supported_orm ⇒ Object
Tell us for now which orm we support.
Instance Method Details
#add_project_module(controller) ⇒ Object
Add access_control permission in our app.rb.
43 44 45 46 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 43 def add_project_module(controller) = " role.project_module :#{controller}, '/#{controller}'\n" inject_into_file destination_root(@admin_path+'/app.rb'), , :after => "access_control.roles_for :admin do |role|\n" end |
#ext ⇒ Object
Tell us which rendering engine you are using.
22 23 24 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 22 def ext fetch_component_choice(:admin_renderer).to_sym rescue :haml end |
#fetch_app_name(app = 'app') ⇒ String
Returns the app_name for the application at root.
71 72 73 74 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 71 def fetch_app_name(app='app') app_path = destination_root(app, 'app.rb') @app_name ||= File.read(app_path).scan(/module\s(.*?)\n/).flatten[0] end |
#orm ⇒ Object Also known as: adapter
Tell us which orm we are using.
14 15 16 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 14 def orm fetch_component_choice(:orm).to_sym rescue :activerecord end |
#remove_project_module(controller) ⇒ Object
Remove from access_control permissions.
51 52 53 54 55 56 57 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 51 def remove_project_module(controller) path = destination_root(@admin_path+'/app.rb') say_status :replace, @admin_path+'/app.rb', :red content = File.binread(path) content.gsub!(/^\s+role\.project_module :#{controller}, '\/#{controller}'\n/, '') File.open(path, 'wb') { |f| f.write content } end |
#supported_ext ⇒ Object
Tell us for now which rendering engine we support.
36 37 38 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 36 def supported_ext [:haml, :slim, :erb] end |
#supported_orm ⇒ Object
Tell us for now which orm we support
29 30 31 |
# File 'padrino-admin/lib/padrino-admin/generators/actions.rb', line 29 def supported_orm [:minirecord, :datamapper, :activerecord, :mongomapper, :mongoid, :couchrest, :sequel, :ohm, :dynamoid] end |