Module: Hello::RailsHelper

Defined in:
lib/hello/rails_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



3
4
5
6
7
8
9
# File 'lib/hello/rails_helper.rb', line 3

def method_missing(method, *args, &block)
  # # http://candland.net/2012/04/17/rails-routes-used-in-an-isolated-engine/
  # puts "LOOKING FOR ROUTES #{method}"
  return super unless method.to_s.end_with?('_path', '_url')
  return super unless main_app.respond_to?(method)
  main_app.send(method, *args)
end

Instance Method Details

#available_locales_with_namesObject



30
31
32
# File 'lib/hello/rails_helper.rb', line 30

def available_locales_with_names
  Hello::Locales.all.select { |k, _v| Hello.configuration.locales.include? k }
end

#current_localeObject



26
27
28
# File 'lib/hello/rails_helper.rb', line 26

def current_locale
  session['locale']
end

#hello_locale_select_optionsObject

[‘English’, ‘en’]


18
19
20
# File 'lib/hello/rails_helper.rb', line 18

def hello_locale_select_options
  available_locales_with_names.map { |k, v| [v, k] }
end

#human_current_localeObject



22
23
24
# File 'lib/hello/rails_helper.rb', line 22

def human_current_locale
  t('hello.locale_name')
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/hello/rails_helper.rb', line 11

def respond_to?(method)
  return super unless method.to_s.end_with?('_path', '_url')
  return super unless main_app.respond_to?(method)
  true
end