Module: Docks::Renderers::Common::Helperable

Included in:
ERB, Haml, Slim
Defined in:
lib/docks/renderers/common_features/helperable.rb

Instance Method Summary collapse

Instance Method Details

#helpers(*helpers) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/docks/renderers/common_features/helperable.rb', line 5

def helpers(*helpers)
  load_helpers = Module.new

  helpers.each do |helper|
    if helper.kind_of?(Module)
      self.send(:extend, helper)
    elsif File.exists?(helper)
      load_helpers.module_eval(File.read(helper), helper, 0)
    end
  end

  load_helpers.constants.each do |constant|
    self.send(:extend, load_helpers.const_get(constant))
  end
end