Exception: Neoway::Auth::BaseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/neoway/auth/base_error.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = self.class.default_message) ⇒ BaseError

Returns a new instance of BaseError.



6
7
8
# File 'lib/neoway/auth/base_error.rb', line 6

def initialize(message = self.class.default_message)
  super(message)
end

Class Method Details

.default_messageObject



10
11
12
13
14
# File 'lib/neoway/auth/base_error.rb', line 10

def self.default_message
  name = self.name.dup

  I18n.t("errors.#{underscore(name)}")
end

.underscore(str) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/neoway/auth/base_error.rb', line 16

def self.underscore(str)
  str.gsub(/::/, ".")
     .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
     .gsub(/([a-z\d])([A-Z])/, '\1_\2')
     .tr("-", "_")
     .downcase
end