Class: WingedCouch::Exceptions::Handlers::Base

Inherits:
Struct
  • Object
show all
Defined in:
lib/winged_couch/exceptions/handlers/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args


4
5
6
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 4

def args
  @args
end

#exceptionObject

Returns the value of attribute exception

Returns:

  • (Object)

    the current value of exception


4
5
6
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 4

def exception
  @exception
end

#http_pathObject

Returns the value of attribute http_path

Returns:

  • (Object)

    the current value of http_path


4
5
6
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 4

def http_path
  @http_path
end

#request_typeObject

Returns the value of attribute request_type

Returns:

  • (Object)

    the current value of request_type


4
5
6
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 4

def request_type
  @request_type
end

Class Method Details

.call(&block) ⇒ Object


49
50
51
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 49

def call(&block)
  define_method(:call, &block)
end

.respond?(&block) ⇒ Boolean

Returns:

  • (Boolean)

45
46
47
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 45

def respond?(&block)
  define_method(:respond?, &block)
end

Instance Method Details

#db_nameObject


6
7
8
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 6

def db_name
  http_path.path[0]
end

#document_nameObject


10
11
12
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 10

def document_name
  http_path.path[1]
end

#errorObject


22
23
24
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 22

def error
  response["error"]
end

#forbidden?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 34

def forbidden?
  exception.is_a?(RestClient::Forbidden)
end

#not_found?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 26

def not_found?
  exception.is_a?(RestClient::ResourceNotFound)
end

#precondition_failed?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 30

def precondition_failed?
  exception.is_a?(RestClient::PreconditionFailed)
end

#reasonObject


18
19
20
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 18

def reason
  response["reason"]
end

#responseObject


14
15
16
# File 'lib/winged_couch/exceptions/handlers/base.rb', line 14

def response
  JSON.parse(exception.response) rescue {}
end