class Terror::ErrorBuilder
Public Class Methods
new(klass, from)
click to toggle source
# File lib/terror.rb, line 13 def initialize(klass, from) @klass = klass @from = from end
Public Instance Methods
method_missing(name, **kwargs, &blk)
click to toggle source
# File lib/terror.rb, line 18 def method_missing(name, **kwargs, &blk) error = ::Class.new(kwargs.fetch(:from, @from), &blk) if kwargs.has_key?(:message) error.class_eval("def message; '#{kwargs.fetch(:message)}'; end") end @klass.const_set(name, error) end