Class: RspecApiDocs::Resource
- Inherits:
-
Object
- Object
- RspecApiDocs::Resource
- Defined in:
- lib/rspec_api_docs/formatter/resource.rb,
lib/rspec_api_docs/formatter/resource/example.rb,
lib/rspec_api_docs/formatter/resource/parameter.rb,
lib/rspec_api_docs/formatter/resource/response_field.rb,
lib/rspec_api_docs/formatter/resource/example/request_headers.rb
Defined Under Namespace
Classes: Example, Parameter, ResponseField
Instance Attribute Summary collapse
-
#rspec_example ⇒ Object
readonly
Returns the value of attribute rspec_example.
Instance Method Summary collapse
-
#add_example(example) ⇒ void
Add an example.
-
#description ⇒ String
The description of the resource.
-
#examples ⇒ Array<Example>
Returns an array of Examples.
-
#initialize(rspec_example) ⇒ Resource
constructor
A new instance of Resource.
-
#name ⇒ String
The name of the resource.
Constructor Details
#initialize(rspec_example) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 9 def initialize(rspec_example) @rspec_example = rspec_example @examples = [] end |
Instance Attribute Details
#rspec_example ⇒ Object (readonly)
Returns the value of attribute rspec_example.
7 8 9 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 7 def rspec_example @rspec_example end |
Instance Method Details
#add_example(example) ⇒ void
This method returns an undefined value.
Add an example
42 43 44 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 42 def add_example(example) @examples << example end |
#description ⇒ String
The description of the resource.
E.g. “Orders can be created, viewed, and deleted”
28 29 30 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 28 def description [:resource_description] end |
#examples ⇒ Array<Example>
Returns an array of Examples
35 36 37 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 35 def examples @examples.sort_by(&:name) end |
#name ⇒ String
The name of the resource.
E.g. “Characters”
19 20 21 |
# File 'lib/rspec_api_docs/formatter/resource.rb', line 19 def name .fetch(:resource_name, rspec_example.[:example_group][:description]) end |