Module: Integral::SupportHelper

Included in:
ApplicationHelper, Backend::BaseHelper
Defined in:
app/helpers/integral/support_helper.rb

Overview

Support Helper which contains common helper methods used within backend & frontend

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Override method_missing to check for main app routes before throwing exception



28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/integral/support_helper.rb', line 28

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

#anchor_to(body, location) ⇒ String

Creates an anchor link

Parameters:

  • body (String)

    body of the link

  • location (String)

    location of the anchor

Returns:

  • (String)

    anchor to a particular location of the current page



20
21
22
23
24
25
# File 'app/helpers/integral/support_helper.rb', line 20

def anchor_to(body, location)
  current_path = url_for(only_path: false)
  path = "#{current_path}##{location}"

  link_to body, path
end

#display_media_query_indicator?Boolean

Green - large screens, medium - tablets, red - mobile

Returns:

  • (Boolean)

    Whether or not to display media query indicator



10
11
12
# File 'app/helpers/integral/support_helper.rb', line 10

def display_media_query_indicator?
  Rails.env.development?
end

#icon(name) ⇒ Object



4
5
6
# File 'app/helpers/integral/support_helper.rb', line 4

def icon(name)
  (:i, nil, class: name)
end

#respond_to?(method, include_all = false) ⇒ Boolean

Override respond_to? to check for main app routes

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/integral/support_helper.rb', line 41

def respond_to?(method, include_all = false)
  if method.to_s.end_with?('_path', '_url')
    if main_app.respond_to?(method)
      true
    else
      super
    end
  else
    super
  end
end