Sha256: 09afbb69b6ffe339e7d1ea2e7f1bfabaaddcb8933a63b134e651aff7737c978c
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
require 'facet/kernel/constant' require 'facet/string/camelize' module Nitro # Helpers are standard Ruby modules that contain utility # methods. By using the special 'helper' # macro provided by Helpers, the utility methods are # included as private methods. # # The helper also requires the ruby file. # # === Examples # # class MyController < Nitro::Controller # helper :xhtml # == include Nitro::XhtmlHelper # end module Helpers module Utils #-- # gmosx: dont name constant to avoid loop. #++ def self.const(mod) return constant(mod) rescue NameError => ex return nil end end def self.append_features(base) super base.module_eval do def self.helper(*modules) for mod in modules #-- # gmosx, FIXME: temp solution, will fix! #++ if mod.is_a? String begin # gmosx: dont interpolate (RDoc fix). require('src/helper/' + mod) rescue Object require('nitro/helper/' + mod) rescue nil end end unless mod.is_a? Module mod = mod.to_s.camelize # gmosx: check xxxHelper before xxx. mod = Utils.const("#{mod}Helper") || Utils.const("Nitro::#{mod}Helper") || Utils.const(mod) end symbols = mod.instance_methods.collect { |m| m.to_sym } self.send(:include, mod) self.send(:private, *symbols) end end end end end end # * George Moschovitis <gm@navel.gr>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.31.0 | lib/nitro/helper.rb |