Class: Exceptor::Base

Inherits:
Object
  • Object
show all
Extended by:
ClassAttr
Defined in:
lib/exceptor/base.rb

Class Method Summary collapse

Methods included from ClassAttr

class_attr

Class Method Details

.inherited(subclass) ⇒ Object



8
9
10
11
# File 'lib/exceptor/base.rb', line 8

def self.inherited(subclass)
  subclass.exceptors = subclass.exceptors.dup if subclass.exceptors
  super
end

.on(exception, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/exceptor/base.rb', line 13

def self.on(exception, &block)
  if exception == :default
    if self.exceptors
      self.exceptors.default = block
    else
      self.exceptors = {}.tap { |o| o.default = block }
    end
  else
    self.exceptors ||= {}
    self.exceptors[exception] = block
  end
end