public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
mack / lib / mack / initialization / helpers.rb
100644 31 lines (27 sloc) 1.143 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Include ApplicationHelper into all controllers:
Mack.logger.debug "Initializing helpers..." unless app_config.log.disable_initialization_logging
# adding application_helper module into all defined controllers
if Object.const_defined?("ApplicationHelper")
  Mack.logger.warn("ApplicationHelper has been deprecated! Please use move it to Mack::ViewHelpers::ApplicationHelper instead.")
  ApplicationHelper.include_safely_into(Mack::Rendering::ViewTemplate)
end
 
module Mack
  module ControllerHelpers # :nodoc:
  end
  
  module ViewHelpers # :nodoc:
  end
end
 
# Find controller level Helpers and include them into their respective controllers
Mack::ControllerHelpers.constants.each do |cont|
  h = "Mack::ControllerHelpers::#{cont}"
  if Object.const_defined?(cont)
    h.constantize.include_safely_into(cont.constantize)
  else
    Mack.logger.warn("Could not find: #{cont} controller for helper: #{h}")
  end
end
 
# Find view level Helpers and include them into the Mack::Rendering::ViewTemplate
Mack::ViewHelpers.constants.each do |cont|
  h = "Mack::ViewHelpers::#{cont}".constantize
  Mack::Rendering::ViewTemplate.send(:include, h)
end