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



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

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



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

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



72
73
74
# File 'app/models/effective/resources/paths.rb', line 72

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


68
69
70
# File 'app/models/effective/resources/paths.rb', line 68

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



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

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



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

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



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

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/models/effective/resources/paths.rb', line 77

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

#wizard_file_path(resource) ⇒ Object

Wizards are kinda weird, we need some help for effective_memberships



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

def wizard_file_path(resource)
  if resource.class.try(:effective_memberships_applicant?) || resource.class.try(:effective_memberships_applicant_review?)
    File.join(*['effective', plural_name].compact)
  else
    view_file_path(nil)
  end
end