Module: Kadim::ApplicationHelper
- Defined in:
- app/helpers/kadim/application_helper.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/helpers/kadim/application_helper.rb', line 33
def method_missing(method, *args, &block)
if method.to_s.end_with?("_path", "_url")
if main_app.respond_to?(method)
main_app.send(method, *args)
else
super
end
else
super
end
end
|
Instance Method Details
#attribute_invalid?(model, attribute) ⇒ Boolean
29
30
31
|
# File 'app/helpers/kadim/application_helper.rb', line 29
def attribute_invalid?(model, attribute)
model.errors.key?(attribute)
end
|
#invalid_attribute_class(model, attribute) ⇒ Object
25
26
27
|
# File 'app/helpers/kadim/application_helper.rb', line 25
def invalid_attribute_class(model, attribute)
attribute_invalid?(model, attribute) ? "is-danger" : ""
end
|
5
6
7
8
9
|
# File 'app/helpers/kadim/application_helper.rb', line 5
def
kadim_link = link_to("Kadim", kadim.root_path)
links =
safe_join([kadim_link] + links, " | ")
end
|
11
12
13
14
15
|
# File 'app/helpers/kadim/application_helper.rb', line 11
def (options = {})
Kadim.app_model_paths.map(&:camelize).map(&:constantize).map do |model_klass|
active_link_to model_klass.model_name.human(count: :many), model_klass, **options
end
end
|
#respond_to?(method) ⇒ Boolean
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/helpers/kadim/application_helper.rb', line 45
def respond_to?(method)
if method.to_s.end_with?("_path", "_url")
if main_app.respond_to?(method)
true
else
super
end
else
super
end
end
|
#upload_type ⇒ Object
17
18
19
20
21
22
23
|
# File 'app/helpers/kadim/application_helper.rb', line 17
def upload_type
case Kadim.upload_type
when :direct then { direct_upload: true }
when :resumable then { resumable_upload: true }
else {}
end
end
|