Class: Trestle::Admin
- Inherits:
-
Object
show all
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/trestle/admin.rb,
lib/trestle/admin/builder.rb,
lib/trestle/admin/controller.rb
Defined Under Namespace
Classes: Builder, Controller
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.additional_routes ⇒ Object
Returns the value of attribute additional_routes.
13
14
15
|
# File 'lib/trestle/admin.rb', line 13
def additional_routes
@additional_routes
end
|
.breadcrumb ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/trestle/admin.rb', line 40
def breadcrumb
if @breadcrumb
Breadcrumb.cast(@breadcrumb.call)
else
default_breadcrumb
end
end
|
Returns the value of attribute form.
11
12
13
|
# File 'lib/trestle/admin.rb', line 11
def form
@form
end
|
Returns the value of attribute menu.
9
10
11
|
# File 'lib/trestle/admin.rb', line 9
def
@menu
end
|
.options ⇒ Object
18
19
20
|
# File 'lib/trestle/admin.rb', line 18
def options
@options ||= {}
end
|
Class Method Details
.actions ⇒ Object
92
93
94
|
# File 'lib/trestle/admin.rb', line 92
def actions
[:index]
end
|
.admin_name ⇒ Object
52
53
54
|
# File 'lib/trestle/admin.rb', line 52
def admin_name
name.underscore.sub(/_admin$/, '')
end
|
.build(&block) ⇒ Object
116
117
118
|
# File 'lib/trestle/admin.rb', line 116
def build(&block)
Admin::Builder.build(self, &block)
end
|
.controller_namespace ⇒ Object
84
85
86
|
# File 'lib/trestle/admin.rb', line 84
def controller_namespace
"#{name.underscore}/admin"
end
|
.controller_path ⇒ Object
80
81
82
|
# File 'lib/trestle/admin.rb', line 80
def controller_path
"admin/#{name.underscore.sub(/_admin$/, '')}"
end
|
.default_breadcrumb ⇒ Object
48
49
50
|
# File 'lib/trestle/admin.rb', line 48
def default_breadcrumb
Breadcrumb.new(human_admin_name, path)
end
|
.human_admin_name ⇒ Object
60
61
62
|
# File 'lib/trestle/admin.rb', line 60
def human_admin_name
I18n.t("admin.breadcrumbs.#{i18n_key}", default: name.demodulize.underscore.sub(/_admin$/, '').titleize)
end
|
.i18n_key ⇒ Object
56
57
58
|
# File 'lib/trestle/admin.rb', line 56
def i18n_key
admin_name
end
|
.parameter_name ⇒ Object
72
73
74
|
# File 'lib/trestle/admin.rb', line 72
def parameter_name
admin_name.singularize
end
|
.path(action = root_action, options = {}) ⇒ Object
88
89
90
|
# File 'lib/trestle/admin.rb', line 88
def path(action=root_action, options={})
Engine.routes.url_for(options.merge(controller: controller_namespace, action: action, only_path: true))
end
|
.railtie_routes_url_helpers(include_path_helpers = true) ⇒ Object
112
113
114
|
# File 'lib/trestle/admin.rb', line 112
def railtie_routes_url_helpers(include_path_helpers=true)
Trestle.railtie_routes_url_helpers(include_path_helpers)
end
|
.root_action ⇒ Object
96
97
98
|
# File 'lib/trestle/admin.rb', line 96
def root_action
:index
end
|
.route_name ⇒ Object
76
77
78
|
# File 'lib/trestle/admin.rb', line 76
def route_name
"#{admin_name.tr('/', '_')}_admin"
end
|
.routes ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/trestle/admin.rb', line 100
def routes
admin = self
Proc.new do
scope controller: admin.controller_namespace, path: admin.options[:path] || admin.admin_name do
get "", action: "index", as: admin.route_name
instance_exec(&admin.additional_routes) if admin.additional_routes
end
end
end
|
.table ⇒ Object
Deprecated: Use ‘tables` instead
27
28
29
|
# File 'lib/trestle/admin.rb', line 27
def table
tables[:index]
end
|
.table=(table) ⇒ Object
Deprecated: Use ‘tables=` instead
32
33
34
|
# File 'lib/trestle/admin.rb', line 32
def table=(table)
tables[:index] = table
end
|
.tables ⇒ Object
22
23
24
|
# File 'lib/trestle/admin.rb', line 22
def tables
@tables ||= {}
end
|
.translate(key, options = {}) ⇒ Object
Also known as:
t
64
65
66
67
68
69
|
# File 'lib/trestle/admin.rb', line 64
def translate(key, options={})
defaults = [:"admin.#{i18n_key}.#{key}", :"admin.#{key}"]
defaults << options[:default] if options[:default]
I18n.t(defaults.shift, options.merge(default: defaults))
end
|
.validate! ⇒ Object
120
121
122
|
# File 'lib/trestle/admin.rb', line 120
def validate!
end
|