Class: RspecApiDocumentation::Writers::JsonIndex
- Inherits:
-
Object
- Object
- RspecApiDocumentation::Writers::JsonIndex
- Defined in:
- lib/rspec_api_documentation/writers/json_iodocs_writer.rb
Direct Known Subclasses
Instance Method Summary collapse
- #as_json(opts = nil) ⇒ Object
- #examples ⇒ Object
-
#initialize(index, configuration) ⇒ JsonIndex
constructor
A new instance of JsonIndex.
- #sections ⇒ Object
Constructor Details
#initialize(index, configuration) ⇒ JsonIndex
Returns a new instance of JsonIndex.
25 26 27 28 |
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 25 def initialize(index, configuration) @index = index @configuration = configuration end |
Instance Method Details
#as_json(opts = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 38 def as_json(opts = nil) sections.inject({:endpoints => []}) do |h, section| h[:endpoints].push( :name => section[:resource_name], :methods => section[:examples].map do |example| example.as_json(opts) end ) h end end |
#examples ⇒ Object
34 35 36 |
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 34 def examples @index.examples.map { |example| JsonIodocsExample.new(example, @configuration) } end |
#sections ⇒ Object
30 31 32 |
# File 'lib/rspec_api_documentation/writers/json_iodocs_writer.rb', line 30 def sections IndexHelper.sections(examples, @configuration) end |