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



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_fileObject



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

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

#controller_fileObject



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_fileObject



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


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

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

#model_fileObject



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_fileObject



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_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



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_pathsObject

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