Class: Jsonorama::JsonResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonorama/json_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ JsonResponse

Returns a new instance of JsonResponse.

Yields:

  • (_self)

Yield Parameters:



6
7
8
9
10
11
12
13
14
# File 'lib/jsonorama/json_response.rb', line 6

def initialize
  self.message = nil
  self.errors = nil
  self.data = Blobject.new
  self.exception = nil
  self.status_code = nil
  yield self if block_given?
  self
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/jsonorama/json_response.rb', line 4

def data
  @data
end

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/jsonorama/json_response.rb', line 4

def errors
  @errors
end

#exceptionObject

Returns the value of attribute exception.



4
5
6
# File 'lib/jsonorama/json_response.rb', line 4

def exception
  @exception
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/jsonorama/json_response.rb', line 4

def message
  @message
end

#status_codeObject

Returns the value of attribute status_code.



4
5
6
# File 'lib/jsonorama/json_response.rb', line 4

def status_code
  @status_code
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/jsonorama/json_response.rb', line 16

def client_error?
  self.status_code.to_s.starts_with? '4'
end

#server_error?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/jsonorama/json_response.rb', line 20

def server_error?
  self.status_code.to_s.starts_with? '5'
end