Class: WingedCouch::Exceptions::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/winged_couch/exceptions/handler.rb

Defined Under Namespace

Classes: DatabaseAlreadyExist, DocumentMissing, InvalidDocument, NoDatabase, NoDesignDocument

Constant Summary collapse

HANDLERS =
[
  NoDatabase,
  DatabaseAlreadyExist,
  DocumentMissing,
  InvalidDocument,
  NoDesignDocument
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_type, http_path, args, exception) ⇒ Handler

Returns a new instance of Handler


10
11
12
13
14
15
# File 'lib/winged_couch/exceptions/handler.rb', line 10

def initialize(request_type, http_path, args, exception)
  @request_type = request_type
  @http_path = http_path
  @args = args
  @exception = exception
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args


8
9
10
# File 'lib/winged_couch/exceptions/handler.rb', line 8

def args
  @args
end

#exceptionObject (readonly)

Returns the value of attribute exception


8
9
10
# File 'lib/winged_couch/exceptions/handler.rb', line 8

def exception
  @exception
end

#http_pathObject (readonly)

Returns the value of attribute http_path


8
9
10
# File 'lib/winged_couch/exceptions/handler.rb', line 8

def http_path
  @http_path
end

#request_typeObject (readonly)

Returns the value of attribute request_type


8
9
10
# File 'lib/winged_couch/exceptions/handler.rb', line 8

def request_type
  @request_type
end

Instance Method Details

#runObject


17
18
19
20
21
22
23
# File 'lib/winged_couch/exceptions/handler.rb', line 17

def run
  HANDLERS.each do |handler_klass|
    handler = handler_klass.new(request_type, http_path, args, exception)
    handler.call if handler.respond?
  end
  raise exception # When nothing found...
end