class ERB::OpenTemplate
OpenTemplate¶ ↑
The Erb OpenTemplate provides a quick and convenient way to create a clean rendering space with the desired responses.
TODO: This might make a good addon library. Just add require 'erb' to the #erb_result method? Call it OpenResponse?
Public Class Methods
new(*objs_ioc)
click to toggle source
# File lib/more/facets/erb.rb, line 19 def initialize(*objs_ioc) ioc = Hash===objs_ioc.last ? objs_ioc.pop : {} objs = objs_ioc mods = [] objs.each do |obj| mod = Module.new obj.public_methods.each do |m| mod.module_eval do define_method(m){ |*a,&b| obj.__send__(m,*a,&b) } end end mods << mod end mod = Module.new ioc.each do |k,v| mod.module_eval do define_method(k){ v } end end mods << mod extend *mods.reverse end
Public Instance Methods
erb_result(str)
click to toggle source
# File lib/more/facets/erb.rb, line 47 def erb_result(str) ERB.new(str).result(binding) end