Sha256: a6320800b1a0686bae1619c1f7f23412ee08a0cf7719057c244db3c48fb19e34
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module AutoError class HelperContext attr_accessor :env def initialize( env ) @env = env AutoError::Config.helpers.each do |mod_name| # grab the module by name we were given # it is available in the 'parent' Rails.application mod = Rails.application.class.qualified_const_get(mod_name) class_eval do # include that module in this HelperContext send( :include, mod ) # but go through all of its instance methods # and alias-method-chain style twiddle them so we can bind # them to the correct environment inside auto_error mod.instance_methods.each do |imeth| alias :"#{imeth}_without_env" :"#{imeth}" send( :define_method, :"#{imeth}" ) do |*args| env.instance_exec( *args, &method( :"#{imeth}_without_env" ) ) end end # also include rails helpers and ActionView helpers send( :include, ActionView::Helpers ) send( :include, Rails.application.routes.url_helpers ) end end end def default_url_options; {}; end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
auto_error-0.0.18 | lib/auto_error/helper_context.rb |
auto_error-0.0.16 | lib/auto_error/helper_context.rb |