Sha256: bea409fc0291c6645a0c1e5829066bb462f290c724f24427a9f78c8b4737a908
Contents?: true
Size: 420 Bytes
Versions: 2
Compression:
Stored size: 420 Bytes
Contents
# p __FILE__ # More later? def make_exception(sym, str, target_class = Object) return if target_class.constants.include?(sym) klass = sym # :"#{sym}_Class" target_class.const_set(klass, StandardError.dup) define_method(sym) do |*args| args = [] unless args.first msg = str.dup args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg) } target_class.class_eval(klass.to_s).new(msg) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
livetext-0.9.24 | lib/errors.rb |
livetext-0.9.23 | lib/errors.rb |