Class: Shaf::Responder::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/responder/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_type:, body:, serialized_hash: {}, resource: nil) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
# File 'lib/shaf/responder/base.rb', line 7

def initialize(content_type:, body:, serialized_hash: {}, resource: nil)
  @content_type = content_type
  @body = body
  @serialized_hash = serialized_hash
  @resource = resource
  @preload_links = []
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/shaf/responder/base.rb', line 4

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



4
5
6
# File 'lib/shaf/responder/base.rb', line 4

def content_type
  @content_type
end

Returns the value of attribute preload_links.



5
6
7
# File 'lib/shaf/responder/base.rb', line 5

def preload_links
  @preload_links
end

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'lib/shaf/responder/base.rb', line 4

def resource
  @resource
end

#serialized_hashObject (readonly)

Returns the value of attribute serialized_hash.



4
5
6
# File 'lib/shaf/responder/base.rb', line 4

def serialized_hash
  @serialized_hash
end

Instance Method Details

#log_entryObject



15
16
17
# File 'lib/shaf/responder/base.rb', line 15

def log_entry
  "Response (#{resource.class}) payload: #{body}"
end