Module: Backup::ErrorsHelper

Included in:
Errors
Defined in:
lib/backup/errors.rb

Overview

  • automatically defines module namespaces referenced under Backup::Errors

  • any constant name referenced that ends with ‘Error’ will be created as a subclass of Backup::Errors::Error

e.g.

err = Backup::Errors::Foo::Bar::FooError.new('error message')
err.message => "Foo::Bar::FooError: error message"

Instance Method Summary collapse

Instance Method Details

#const_missing(const) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/backup/errors.rb', line 13

def const_missing(const)
  if const.to_s.end_with?('Error')
    module_eval("class #{const} < Backup::Errors::Error; end")
  else
    module_eval("module #{const}; extend Backup::ErrorsHelper; end")
  end
  const_get(const)
end