Class: Dox::Entities::Example

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dox/entities/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(details, request, response) ⇒ Example

Returns a new instance of Example.



11
12
13
14
15
16
17
18
19
# File 'lib/dox/entities/example.rb', line 11

def initialize(details, request, response)
  @desc = details[:description]
  @name = details[:resource_name].downcase
  @request_schema = details[:action_request_schema]
  @response_schema_success = details[:action_response_schema_success]
  @response_schema_fail = details[:action_response_schema_fail]
  @request = request
  @response = response
end

Instance Attribute Details

#descObject (readonly)

Returns the value of attribute desc.



6
7
8
# File 'lib/dox/entities/example.rb', line 6

def desc
  @desc
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/dox/entities/example.rb', line 6

def name
  @name
end

#request_schemaObject (readonly)

Returns the value of attribute request_schema.



6
7
8
# File 'lib/dox/entities/example.rb', line 6

def request_schema
  @request_schema
end

#response_schema_failObject (readonly)

Returns the value of attribute response_schema_fail.



6
7
8
# File 'lib/dox/entities/example.rb', line 6

def response_schema_fail
  @response_schema_fail
end

#response_schema_successObject (readonly)

Returns the value of attribute response_schema_success.



6
7
8
# File 'lib/dox/entities/example.rb', line 6

def response_schema_success
  @response_schema_success
end

Instance Method Details

#request_bodyObject



21
22
23
# File 'lib/dox/entities/example.rb', line 21

def request_body
  @request_body ||= format_content(request, request_content_type)
end

#request_content_typeObject

Rails 7 changes content_type result



55
56
57
# File 'lib/dox/entities/example.rb', line 55

def request_content_type
  request.respond_to?(:media_type) ? request.media_type : request.content_type
end

#request_fullpathObject

Rails 4 includes the body params in the request_fullpath



46
47
48
49
50
51
52
# File 'lib/dox/entities/example.rb', line 46

def request_fullpath
  if request.query_parameters.present?
    "#{request_path}?#{request_url_query_parameters}"
  else
    request_path
  end
end

#request_headersObject



37
38
39
# File 'lib/dox/entities/example.rb', line 37

def request_headers
  @request_headers ||= filter_headers(request)
end

#request_identifierObject



29
30
31
# File 'lib/dox/entities/example.rb', line 29

def request_identifier
  @desc
end

#response_bodyObject



25
26
27
# File 'lib/dox/entities/example.rb', line 25

def response_body
  @response_body ||= format_content(response, response_content_type)
end

#response_content_typeObject



59
60
61
# File 'lib/dox/entities/example.rb', line 59

def response_content_type
  response.respond_to?(:media_type) ? response.media_type : response.content_type
end

#response_headersObject



33
34
35
# File 'lib/dox/entities/example.rb', line 33

def response_headers
  @response_headers ||= filter_headers(response)
end

#response_success?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/dox/entities/example.rb', line 41

def response_success?
  response.successful?
end