Exception: Libcouchbase::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Libcouchbase::Error
- Defined in:
- lib/libcouchbase/error.rb,
lib/libcouchbase/error.rb
Direct Known Subclasses
Defined Under Namespace
Classes: HttpResponseError, UnknownError
Constant Summary collapse
- Lookup =
{}
- Ignore =
Dynamically define the error classes
['empty', 'error', 'environment']
- Map =
{ 'noent' => 'not_found', 'nomem' => 'no_memory', 'noconf' => 'no_config', '2big' => 'too_big', '2deep' => 'too_deep', 'inval' => 'invalid' }
Class Method Summary collapse
- .camelize(term, uppercase_first_letter = true) ⇒ Object
-
.lookup(key) ⇒ Object
Provide a helper.
Class Method Details
.camelize(term, uppercase_first_letter = true) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/libcouchbase/error.rb', line 15 def self.camelize(term, uppercase_first_letter = true) string = term.to_s if uppercase_first_letter string = string.sub(/^[a-z\d]*/) { |match| match.capitalize } else string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { |match| match.downcase } end string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" } string.gsub!('/', '::') string end |
.lookup(key) ⇒ Object
Provide a helper
63 64 65 66 |
# File 'lib/libcouchbase/error.rb', line 63 def self.lookup(key) look = key.is_a?(Numeric) ? Ext::ErrorT[key] : key.to_sym Lookup[look] || UnknownError end |