Module: Racket::Utils::Helpers

Included in:
ToolBelt
Defined in:
lib/racket/utils/helpers.rb

Overview

Utility functions for routing.

Defined Under Namespace

Classes: HelperCache

Instance Method Summary collapse

Instance Method Details

#__apply_helpers(klass) ⇒ Class

Applies helpers to a controller class by including the modules in the class.

Parameters:

  • klass (Class)

Returns:

  • (Class)


106
107
108
109
110
111
112
113
114
# File 'lib/racket/utils/helpers.rb', line 106

def __apply_helpers(klass)
  klass.settings.fetch(:helpers).reverse_each do |pair|
    helper_key, helper = pair
    klass.context.logger.inform_dev(
      "Adding helper module #{helper_key.inspect} to #{klass}"
    )
    klass.send(:include, helper)
  end
end

#apply_helpers(klass) ⇒ Object

Applies helpers to a controller class by including the modules in the class.

Parameters:

  • klass (Class)


96
97
98
99
100
# File 'lib/racket/utils/helpers.rb', line 96

def apply_helpers(klass)
  klass.helper unless klass.settings.fetch(:helpers) # Makes sure default helpers are loaded.
  __apply_helpers(klass)
  nil
end