class ThreeScale::Core::Error

Public Class Methods

code() click to toggle source
# File lib/3scale/core/errors.rb, line 18
def self.code
  underscore(name[/[^:]*$/])
end
underscore(string) click to toggle source

TODO: move this over to some utility module.

# File lib/3scale/core/errors.rb, line 23
def self.underscore(string)
  # Code stolen from ActiveSupport
  string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
         gsub(/([a-z\d])([A-Z])/,'\1_\2').
         downcase
end

Public Instance Methods

code() click to toggle source
# File lib/3scale/core/errors.rb, line 14
def code
  self.class.code
end
to_xml(options = {}) click to toggle source
# File lib/3scale/core/errors.rb, line 6
def to_xml(options = {})
  xml = Builder::XmlMarkup.new
  xml.instruct! unless options[:skip_instruct]
  xml.error(message, :code => code)

  xml.target!
end