Sha256: e11306285e4e5ea40e794d43adf53fb53bacbb428dbfd97097c5a7f06b68202e

Contents?: true

Size: 913 Bytes

Versions: 5

Compression:

Stored size: 913 Bytes

Contents

# encoding: utf-8

module RedisDictionary
  module ApplicationHelper
    def title(page_title, show_title = true)
      @show_title = show_title
      if @show_title
        content_for(:title) { h(page_title.to_s) }
      end
    end

    def show_title?
      @show_title
    end

    def humanize_key(key)
      key.split('.').last.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
    end

    # Can search for named routes directly in the main app, omitting
    # the "main_app." prefix
    def method_missing method, *args, &block
      if main_app_url_helper?(method)
        main_app.send(method, *args)
      else
        super
      end
    end

    private

    def main_app_url_helper?(method)
      RedisDictionary::configuration.inline_main_app_named_routes and
        (method.to_s.end_with?('_path') or method.to_s.end_with?('_url')) and
        main_app.respond_to?(method)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis_dictionary-1.0.2 app/helpers/redis_dictionary/application_helper.rb
redis_dictionary-1.0.1 app/helpers/redis_dictionary/application_helper.rb
redis_dictionary-1.0.0 app/helpers/redis_dictionary/application_helper.rb
redis_dictionary-0.9.9 app/helpers/redis_dictionary/application_helper.rb
redis_dictionary-0.9.8 app/helpers/redis_dictionary/application_helper.rb