Module: Effective::Resources::Paths

Included in:
Effective::Resource
Defined in:
app/models/effective/resources/paths.rb

Instance Method Summary collapse

Instance Method Details

#abilities_fileObject



55
56
57
# File 'app/models/effective/resources/paths.rb', line 55

def abilities_file
  File.join(*[tenant_path, 'app/models/', class_path, 'ability.rb'].compact)
end

#admin_effective_controller_fileObject



21
22
23
# File 'app/models/effective/resources/paths.rb', line 21

def admin_effective_controller_file
  File.join(*[tenant_path, 'app/controllers', namespace, "#{plural_name}_controller.rb"].compact)
end

#admin_effective_datatable_fileObject



34
35
36
# File 'app/models/effective/resources/paths.rb', line 34

def admin_effective_datatable_file
  File.join(*[tenant_path, 'app/datatables', namespace, "effective_#{plural_name}_datatable.rb"].compact)
end

#admin_effective_view_file(action = :index, partial: false) ⇒ Object



47
48
49
# File 'app/models/effective/resources/paths.rb', line 47

def admin_effective_view_file(action = :index, partial: false)
  File.join(*[tenant_path, 'app/views', namespace, plural_name, "#{'_' if partial}#{action}.html.haml"].compact)
end

#admin_menu_fileObject



63
64
65
# File 'app/models/effective/resources/paths.rb', line 63

def admin_menu_file
  File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar_admin.html.haml'].compact)
end

#controller_fileObject

Controller



17
18
19
# File 'app/models/effective/resources/paths.rb', line 17

def controller_file
  File.join(*[tenant_path, 'app/controllers', class_path, namespace, "#{plural_name}_controller.rb"].compact)
end

#datatable_fileObject

Datatable



26
27
28
# File 'app/models/effective/resources/paths.rb', line 26

def datatable_file
  File.join(*[tenant_path, 'app/datatables', class_path, namespace, "#{plural_name}_datatable.rb"].compact)
end

#effective_datatable_fileObject



30
31
32
# File 'app/models/effective/resources/paths.rb', line 30

def effective_datatable_file
  File.join(*[tenant_path, 'app/datatables', namespace, "effective_#{plural_name}_datatable.rb"].compact)
end


59
60
61
# File 'app/models/effective/resources/paths.rb', line 59

def menu_file
  File.join(*[tenant_path, 'app/views/layouts', class_path, '_navbar.html.haml'].compact)
end

#model_fileObject

Model



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_fileObject



51
52
53
# File 'app/models/effective/resources/paths.rb', line 51

def routes_file
  File.join(*[tenant_path, 'config/routes.rb'].compact)
end

#tenant_pathObject



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

Views



39
40
41
# File 'app/models/effective/resources/paths.rb', line 39

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



43
44
45
# File 'app/models/effective/resources/paths.rb', line 43

def view_file_path(action = :index)
  File.join(*[class_path, namespace, plural_name, action].compact)
end

#view_pathsObject

Used by render_resource_partial and render_resource_form to guess the view path



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/models/effective/resources/paths.rb', line 68

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