Class: Restify::Processors::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/restify/processors/json.rb

Overview

Decode plain JSON responses.

JSON fields matching *_url will be parsed as relations.

Class Attribute Summary collapse

Attributes inherited from Base

#context, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#body, #initialize, #resource

Constructor Details

This class inherits a constructor from Restify::Processors::Base

Class Attribute Details

.indifferent_access=(value) ⇒ Object (writeonly)

Sets the attribute indifferent_access

Parameters:

  • value

    the value to set the attribute indifferent_access to.



86
87
88
# File 'lib/restify/processors/json.rb', line 86

def indifferent_access=(value)
  @indifferent_access = value
end

Class Method Details

.accept?(response) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/restify/processors/json.rb', line 78

def accept?(response)
  response.content_type =~ %r{\Aapplication/json($|;)}
end

.indifferent_access?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/restify/processors/json.rb', line 82

def indifferent_access?
  @indifferent_access
end

Instance Method Details

#loadObject



14
15
16
# File 'lib/restify/processors/json.rb', line 14

def load
  parse ::JSON.parse(body), root: true
end