Class: RspecApiDocumentation::Writers::JsonIodocsExample
- Inherits:
-
Object
- Object
- RspecApiDocumentation::Writers::JsonIodocsExample
show all
- Defined in:
- lib/rspec_api_documentation/writers/json_iodocs_writer.rb
Instance Method Summary
collapse
Constructor Details
#initialize(example, configuration) ⇒ JsonIodocsExample
Returns a new instance of JsonIodocsExample.
52
53
54
|
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 52
def initialize(example, configuration)
@example = example
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
56
57
58
|
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 56
def method_missing(method, *args, &block)
@example.send(method, *args, &block)
end
|
Instance Method Details
#as_json(opts = nil) ⇒ Object
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 75
def as_json(opts = nil)
{
:MethodName => description,
:Synopsis => explanation,
:HTTPMethod => http_method,
:URI => (requests.first[:request_path] rescue ""),
:RequiresOAuth => "N",
:parameters => parameters
}
end
|
#parameters ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 60
def parameters
params = []
if @example.respond_to?(:parameters)
@example.parameters.map do |param|
params << {
"Name" => param[:name],
"Description" => param[:description],
"Default" => "",
"Required" => param[:required] ? "Y" : "N"
}
end
end
params
end
|