Class: Dox::Entities::Example
- Inherits:
-
Object
- Object
- Dox::Entities::Example
- Extended by:
- Forwardable
- Defined in:
- lib/dox/entities/example.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#request_schema ⇒ Object
readonly
Returns the value of attribute request_schema.
-
#response_schema_fail ⇒ Object
readonly
Returns the value of attribute response_schema_fail.
-
#response_schema_success ⇒ Object
readonly
Returns the value of attribute response_schema_success.
Instance Method Summary collapse
-
#initialize(details, request, response) ⇒ Example
constructor
A new instance of Example.
- #request_body ⇒ Object
-
#request_content_type ⇒ Object
Rails 7 changes content_type result.
-
#request_fullpath ⇒ Object
Rails 4 includes the body params in the request_fullpath.
- #request_headers ⇒ Object
- #request_identifier ⇒ Object
- #response_body ⇒ Object
- #response_content_type ⇒ Object
- #response_headers ⇒ Object
- #response_success? ⇒ Boolean
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
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
6 7 8 |
# File 'lib/dox/entities/example.rb', line 6 def desc @desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/dox/entities/example.rb', line 6 def name @name end |
#request_schema ⇒ Object (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_fail ⇒ Object (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_success ⇒ Object (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_body ⇒ Object
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_type ⇒ Object
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_fullpath ⇒ Object
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_headers ⇒ Object
37 38 39 |
# File 'lib/dox/entities/example.rb', line 37 def request_headers @request_headers ||= filter_headers(request) end |
#request_identifier ⇒ Object
29 30 31 |
# File 'lib/dox/entities/example.rb', line 29 def request_identifier @desc end |
#response_body ⇒ Object
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_type ⇒ Object
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_headers ⇒ Object
33 34 35 |
# File 'lib/dox/entities/example.rb', line 33 def response_headers @response_headers ||= filter_headers(response) end |
#response_success? ⇒ Boolean
41 42 43 |
# File 'lib/dox/entities/example.rb', line 41 def response_success? response.successful? end |