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

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)
  permission = "      role.project_module :#{controller}, '/#{controller}'\n"
  inject_into_file destination_root(@admin_path+'/app.rb'),  permission, :after => "access_control.roles_for :admin do |role|\n"
end

#extObject

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.

Examples:

fetch_app_name('subapp')

Parameters:

  • app (String) (defaults to: 'app')

    folder name of application.

Returns:

  • (String)

    module name for application.



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

#ormObject 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_extObject

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_ormObject

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