Module: ExceptionTransformer::Reportable::ClassMethods

Defined in:
lib/exception_transformer/reportable.rb

Instance Method Summary collapse

Instance Method Details

#as_reportableObject

Returns a subclass ‘Reportable_<name>’ of the current class that includes ‘Reportable`. This subclass is created the first time this method is called and reused for subsequent invocations.



33
34
35
36
37
38
39
40
# File 'lib/exception_transformer/reportable.rb', line 33

def as_reportable
  return self if self <= ReportableException

  name = reportable_name
  mod = self.respond_to?(:module_parent) ? module_parent : parent

  mod.const_defined?(name) ? mod.const_get(name) : mod.const_set(name, build_reportable)
end

#reported_classObject



49
50
51
# File 'lib/exception_transformer/reportable.rb', line 49

def reported_class
  @reported_class ||= self
end

#reported_class=(klass) ⇒ Object



53
54
55
# File 'lib/exception_transformer/reportable.rb', line 53

def reported_class=(klass)
  @reported_class = klass
end

#unload_reportableObject



42
43
44
45
46
47
# File 'lib/exception_transformer/reportable.rb', line 42

def unload_reportable
  name = reportable_name
  mod = self.respond_to?(:module_parent) ? module_parent : parent

  mod.send(:remove_const, name) if mod.const_defined?(name)
end