Sha256: 650fea781b84955c37dfcbb48d9af3a5a268553d5d1407d63827be161185de9e

Contents?: true

Size: 336 Bytes

Versions: 1

Compression:

Stored size: 336 Bytes

Contents

# More later?

def make_exception(sym, str, target_class = Object)
  return if target_class.constants.include?(sym)
  target_class.const_set(sym, StandardError.dup)
  define_method(sym) do |*args|
    msg = str.dup
    args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg) }
    target_class.class_eval(sym.to_s).new(msg)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
livetext-0.9.13 lib/errors.rb