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



21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/kadim/application_helper.rb', line 21

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



5
6
7
8
9
10
11
# File 'app/helpers/kadim/application_helper.rb', line 5

def menu_links
  kadim_link = link_to("Kadim", kadim.root_path)
  links = Kadim.app_model_paths.map(&:camelize).map(&:constantize).map do |model_klass|
    link_to model_klass.model_name.human(count: :many), model_klass
  end
  safe_join([kadim_link] + links, " | ")
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/kadim/application_helper.rb', line 33

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_typeObject



13
14
15
16
17
18
19
# File 'app/helpers/kadim/application_helper.rb', line 13

def upload_type
  case Kadim.upload_type
  when :direct then { direct_upload: true }
  when :resumable then { resumable_upload: true }
  else {}
  end
end