Module: Effective::Resources::Paths
- Included in:
- Effective::Resource
- Defined in:
- app/models/effective/resources/paths.rb
Instance Method Summary collapse
- #abilities_file ⇒ Object
- #admin_menu_file ⇒ Object
- #controller_file ⇒ Object
- #datatable_file ⇒ Object
- #flat_view_file(action = :index, partial: false) ⇒ Object
- #menu_file ⇒ Object
- #model_file ⇒ Object
- #routes_file ⇒ Object
- #tenant_path ⇒ Object
- #view_file(action = :index, partial: false) ⇒ Object
- #view_file_path(action = :index) ⇒ Object
-
#view_paths ⇒ Object
Used by render_resource_partial and render_resource_form to guess the view path.
Instance Method Details
#abilities_file ⇒ Object
40 41 42 |
# File 'app/models/effective/resources/paths.rb', line 40 def abilities_file File.join(*[tenant_path, 'app/models/', class_path, 'ability.rb'].compact) end |
#admin_menu_file ⇒ Object
48 49 50 |
# File 'app/models/effective/resources/paths.rb', line 48 def File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar_admin.html.haml'].compact) end |
#controller_file ⇒ Object
16 17 18 |
# File 'app/models/effective/resources/paths.rb', line 16 def controller_file File.join(*[tenant_path, 'app/controllers', class_path, namespace, "#{plural_name}_controller.rb"].compact) end |
#datatable_file ⇒ Object
20 21 22 |
# File 'app/models/effective/resources/paths.rb', line 20 def datatable_file File.join(*[tenant_path, 'app/datatables', class_path, namespace, "#{plural_name}_datatable.rb"].compact) end |
#flat_view_file(action = :index, partial: false) ⇒ Object
32 33 34 |
# File 'app/models/effective/resources/paths.rb', line 32 def flat_view_file(action = :index, partial: false) File.join(*[tenant_path, 'app/views', class_path, plural_name, "#{'_' if partial}#{action}.html.haml"].compact) end |
#menu_file ⇒ Object
44 45 46 |
# File 'app/models/effective/resources/paths.rb', line 44 def File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar.html.haml'].compact) end |
#model_file ⇒ Object
12 13 14 |
# File 'app/models/effective/resources/paths.rb', line 12 def model_file File.join(*[tenant_path, 'app/models', class_path, "#{name}.rb"].compact) end |
#routes_file ⇒ Object
36 37 38 |
# File 'app/models/effective/resources/paths.rb', line 36 def routes_file File.join(*[tenant_path, 'config/routes.rb'].compact) end |
#tenant_path ⇒ Object
7 8 9 10 |
# File 'app/models/effective/resources/paths.rb', line 7 def tenant_path return unless tenant.present? Tenant.engine_path(tenant).sub("#{Rails.root}/", '') end |
#view_file(action = :index, partial: false) ⇒ Object
24 25 26 |
# File 'app/models/effective/resources/paths.rb', line 24 def view_file(action = :index, partial: false) File.join(*[tenant_path, 'app/views', class_path, namespace, plural_name, "#{'_' if partial}#{action}.html.haml"].compact) end |
#view_file_path(action = :index) ⇒ Object
28 29 30 |
# File 'app/models/effective/resources/paths.rb', line 28 def view_file_path(action = :index) File.join(*[class_path, namespace, plural_name, action].compact) end |
#view_paths ⇒ Object
Used by render_resource_partial and render_resource_form to guess the view path
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/models/effective/resources/paths.rb', line 53 def view_paths mod = class_name.split('::').first.downcase [ [mod, *namespace, plural_name].join('/'), [mod, *namespace, name].join('/'), [*namespace, mod, plural_name].join('/'), [*namespace, mod, name].join('/'), [mod, plural_name].join('/'), [mod, name].join('/'), [*namespace, plural_name].join('/'), [*namespace, name].join('/') ] end |