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.

Constant Summary collapse

@@indifferent_access =
true

Instance Attribute Summary

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 Method Details

.accept?(response) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/restify/processors/json.rb', line 69

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

.indifferent_access=(value) ⇒ Object



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

def indifferent_access=(value)
  @@indifferent_access = value
end

.indifferent_access?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/restify/processors/json.rb', line 73

def indifferent_access?
  @@indifferent_access
end

Instance Method Details

#loadObject



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

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