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.



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

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



23
24
25
# File 'lib/dox/entities/example.rb', line 23

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

#request_fullpathObject

Rails 4 includes the body params in the request_fullpath



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

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

#request_headersObject



39
40
41
# File 'lib/dox/entities/example.rb', line 39

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

#request_identifierObject



31
32
33
# File 'lib/dox/entities/example.rb', line 31

def request_identifier
  @desc
end

#response_bodyObject



27
28
29
# File 'lib/dox/entities/example.rb', line 27

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

#response_headersObject



35
36
37
# File 'lib/dox/entities/example.rb', line 35

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

#response_success?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/dox/entities/example.rb', line 43

def response_success?
  response.successful?
end