Sha256: fe424d62f39d6ec81a4e5a0719823c977aeec386e994a28d42828f761733f2e7
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require 'facet/kernel/constant' require 'facet/string/camelize' require 'glue/attribute' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.29.0 | lib/nitro/helper.rb |
nitro-0.28.0 | lib/nitro/helper.rb |
nitro-0.30.0 | lib/nitro/helper.rb |