Class: Avo::ApplicationController
Instance Method Summary
collapse
#add_breadcrumb, #avo_breadcrumbs
Methods included from UrlHelpers
#edit_resource_path, #new_resource_path, #related_resources_path, #resource_attach_path, #resource_detach_path, #resource_path, #resource_view_path, #resources_path
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #mount_path, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg, #white_panel_classes
Instance Method Details
#_current_user ⇒ Object
96
97
98
|
# File 'app/controllers/avo/application_controller.rb', line 96
def _current_user
instance_eval(&Avo.configuration.current_user)
end
|
#check_avo_license ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/avo/application_controller.rb', line 71
def check_avo_license
if on_custom_tool_page
if @license.lacks(:custom_tools) || @license.invalid?
message = "Your license is invalid or doesn't support custom tools."
end
end
if on_dashboards_path
if @license.lacks(:dashboards) || @license.invalid?
message = "Your license is invalid or doesn't support dashboards."
end
end
if message.present?
if Rails.env.development? || Rails.env.test?
@custom_tools_alert_visible = message
elsif @license.lacks_with_trial(:custom_tools)
raise Avo::LicenseInvalidError, message
end
end
end
|
#context ⇒ Object
100
101
102
|
# File 'app/controllers/avo/application_controller.rb', line 100
def context
instance_eval(&Avo.configuration.context)
end
|
#exception_logger(exception) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/avo/application_controller.rb', line 40
def exception_logger(exception)
respond_to do |format|
format.html { raise exception }
format.json {
render json: {
errors: exception.respond_to?(:record) && exception.record.present? ? exception.record.errors : [],
message: exception.message,
traces: exception.backtrace
}, status: ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
}
end
end
|
#init_app ⇒ Object
34
35
36
37
38
|
# File 'app/controllers/avo/application_controller.rb', line 34
def init_app
Avo::App.init request: request, context: context, current_user: _current_user, view_context: view_context, params: params
@license = Avo::App.license
end
|
#render(*args) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/avo/application_controller.rb', line 53
def render(*args)
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:check_avo_license).source_location.first.match?(/.*\/app\/controllers\/avo\/application_controller\.rb/)
if params[:controller] == "avo/search" && params[:action] == "index"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:index).source_location.first.match?(/.*\/app\/controllers\/avo\/search_controller\.rb/)
end
if params[:controller] == "avo/dashboards" && params[:action] == "show"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:show).source_location.first.match?(/.*\/app\/controllers\/avo\/dashboards_controller\.rb/)
end
if params[:controller] == "avo/dashboards" && params[:action] == "card"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:card).source_location.first.match?(/.*\/app\/controllers\/avo\/dashboards_controller\.rb/)
end
super(*args)
end
|
#turbo_frame_request? ⇒ Boolean
This is coming from Turbo::Frames::FrameRequest module. Exposing it as public method
106
107
108
|
# File 'app/controllers/avo/application_controller.rb', line 106
def turbo_frame_request?
super
end
|