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
-
#anchor_to(body, location) ⇒ String
Creates an anchor link.
-
#display_media_query_indicator? ⇒ Boolean
Green - large screens, medium - tablets, red - mobile.
-
#method_missing(method, *args, &block) ⇒ Object
Override method_missing to check for main app routes before throwing exception.
-
#render_flashes ⇒ String
Markup listing flash notifications.
-
#respond_to?(method, include_all = false) ⇒ Boolean
Override respond_to? to check for main app routes.
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
35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/integral/support_helper.rb', line 35 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
27 28 29 30 31 32 |
# File 'app/helpers/integral/support_helper.rb', line 27 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
6 7 8 |
# File 'app/helpers/integral/support_helper.rb', line 6 def display_media_query_indicator? Rails.env.development? end |
#render_flashes ⇒ String
Returns markup listing flash notifications.
11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/integral/support_helper.rb', line 11 def render_flashes flash_types = %i[notice alert error] content_tag :div, id: :flash_list do flash_types.each do |type| concat render_flash(type, flash[type]) if flash[type].present? end end end |
#respond_to?(method, include_all = false) ⇒ Boolean
Override respond_to? to check for main app routes
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/integral/support_helper.rb', line 48 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 |