Class: RspecApiDocs::Renderer::RaddocsRenderer::IndexSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_api_docs/formatter/renderer/raddocs_renderer/index_serializer.rb

Defined Under Namespace

Classes: ExampleSerializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources) ⇒ IndexSerializer


39
40
41
# File 'lib/rspec_api_docs/formatter/renderer/raddocs_renderer/index_serializer.rb', line 39

def initialize(resources)
  @resources = resources
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources


37
38
39
# File 'lib/rspec_api_docs/formatter/renderer/raddocs_renderer/index_serializer.rb', line 37

def resources
  @resources
end

Instance Method Details

#to_hObject


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rspec_api_docs/formatter/renderer/raddocs_renderer/index_serializer.rb', line 43

def to_h
  {
    resources: resources.map do |resource|
      {
        name: resource.name,
        explanation: nil,
        examples: resource.examples.map { |example| ExampleSerializer.new(example, resource.name).to_h },
      }
    end,
  }
end