Class: Restify::Processors::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/restify/processors/base.rb,
lib/restify/processors/base/parsing.rb

Direct Known Subclasses

Json, Msgpack

Defined Under Namespace

Modules: Parsing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, response) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/restify/processors/base.rb', line 10

def initialize(context, response)
  @context  = context
  @response = response
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/restify/processors/base.rb', line 8

def context
  @context
end

#responseObject (readonly)

Returns the value of attribute response.



8
9
10
# File 'lib/restify/processors/base.rb', line 8

def response
  @response
end

Class Method Details

.accept?(_response) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/restify/processors/base.rb', line 57

def accept?(_response)
  false
end

Instance Method Details

#bodyObject



38
# File 'lib/restify/processors/base.rb', line 38

delegate body: :@response

#loadObject

Return resource or data.

Should be overridden in subclass.



32
33
34
# File 'lib/restify/processors/base.rb', line 32

def load
  body
end

#resourceObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/restify/processors/base.rb', line 15

def resource
  @resource ||= begin
    resource = load

    resource = Resource.new context, response: response, data: resource unless resource.is_a? Restify::Resource

    resource._restify_response = response
    merge_relations! resource._restify_relations

    resource
  end
end