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
39 40 41 |
# File 'app/models/effective/resources/paths.rb', line 39 def abilities_file File.join(*[tenant_path, 'app/models/', class_path, 'ability.rb'].compact) end |
#admin_menu_file ⇒ Object
47 48 49 |
# File 'app/models/effective/resources/paths.rb', line 47 def File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar_admin.html.haml'].compact) end |
#controller_file ⇒ Object
15 16 17 |
# File 'app/models/effective/resources/paths.rb', line 15 def controller_file File.join(*[tenant_path, 'app/controllers', class_path, namespace, "#{plural_name}_controller.rb"].compact) end |
#datatable_file ⇒ Object
19 20 21 |
# File 'app/models/effective/resources/paths.rb', line 19 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
31 32 33 |
# File 'app/models/effective/resources/paths.rb', line 31 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
43 44 45 |
# File 'app/models/effective/resources/paths.rb', line 43 def File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar.html.haml'].compact) end |
#model_file ⇒ Object
11 12 13 |
# File 'app/models/effective/resources/paths.rb', line 11 def model_file File.join(*[tenant_path, 'app/models', class_path, "#{name}.rb"].compact) end |
#routes_file ⇒ Object
35 36 37 |
# File 'app/models/effective/resources/paths.rb', line 35 def routes_file File.join(*[tenant_path, 'config/routes.rb'].compact) end |
#tenant_path ⇒ Object
7 8 9 |
# File 'app/models/effective/resources/paths.rb', line 7 def tenant_path Tenant.engine_path(tenant).sub("#{Rails.root}/", '') if tenant? end |
#view_file(action = :index, partial: false) ⇒ Object
23 24 25 |
# File 'app/models/effective/resources/paths.rb', line 23 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
27 28 29 |
# File 'app/models/effective/resources/paths.rb', line 27 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
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/effective/resources/paths.rb', line 52 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 |