module Grouik::Helpers

Helpers (loader)

Provide easy access to helpers

Public Class Methods

get(target) click to toggle source

Retrieve helper by name

@param [String|Symbol] target @return [Object]

# File src/lib/grouik/helpers.rb, line 21
def get(target)
  class_name = self.classify(target)

  require load_dir.join(target.to_s) unless const_defined?(class_name)

  inflector.constantize(class_name).new
end
load_dir() click to toggle source

Directory where helpers stand

@return [Pathname]

# File src/lib/grouik/helpers.rb, line 32
def load_dir
  Pathname.new(__FILE__.gsub(/\.rb$/, ''))
end

Protected Class Methods

classify(target) click to toggle source

Transform string

return [String]

# File src/lib/grouik/helpers.rb, line 46
def classify(target)
  '%s::%s' % [name, inflector.classify(target.to_s.gsub('/', '::'))]
end
inflector() click to toggle source

@return ActiveSupport::Inflector

# File src/lib/grouik/helpers.rb, line 39
def inflector
  ActiveSupport::Inflector
end