class Yp::Response::GatewayError::Factory

Public Class Methods

error_map() click to toggle source
# File lib/response/gateway_error.rb, line 14
def error_map
  @error_map ||= load_error_map
end
new(code, message) click to toggle source
# File lib/response/gateway_error.rb, line 25
def initialize(code, message)
  @code = code
  @message = message
end

Private Class Methods

load_error_map() click to toggle source
# File lib/response/gateway_error.rb, line 20
def load_error_map
  YAML.load(File.read("#{Yp.data_files_path}/gateway_responses.yml"))
end

Public Instance Methods

error() click to toggle source
# File lib/response/gateway_error.rb, line 30
def error
  if is_missing_field?
    MissingFieldError.new(missing_field)
  elsif is_invalid_field?
    InvalidFieldError.new(invalid_field)
  else
    GatewayError.new(@message)
  end
end

Private Instance Methods

invalid_field() click to toggle source
# File lib/response/gateway_error.rb, line 54
def invalid_field
  @invalid_field ||= mapped_error(:invalid_field)
end
is_invalid_field?() click to toggle source
# File lib/response/gateway_error.rb, line 50
def is_invalid_field?
  !invalid_field.nil?
end
is_missing_field?() click to toggle source
# File lib/response/gateway_error.rb, line 42
def is_missing_field?
  !missing_field.nil?
end
mapped_error(sym) click to toggle source
# File lib/response/gateway_error.rb, line 58
def mapped_error(sym)
  Factory.error_map[sym.to_s][@code.to_i]
end
missing_field() click to toggle source
# File lib/response/gateway_error.rb, line 46
def missing_field
  @missing_field ||= mapped_error(:missing_field)
end