Class: GrapeDocs::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/grape_docs/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grape) ⇒ Api

Returns a new instance of Api.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/grape_docs/api.rb', line 5

def initialize(grape)
  desc = grape.inheritable_setting.namespace[:description]
  @public = desc[:public] || false
  @title = desc ? desc[:description] : grape.name.titlecase
  @detail = desc ? desc[:detail] : nil
  @path = File.join(grape.inheritable_setting.namespace_stackable[:mount_path])
  @url = File.join(GrapeDocs.config[:api_host], @path)
  @endpoints = []
  @children = []
  grape.endpoints.each do |endpoint|
    if endpoint.options.key?(:app)
      api = Api.new(endpoint.options[:app])
      @children.push(api) if api.public
    elsif endpoint.routes.count > 0
      @endpoints.push(Endpoint.new(self, endpoint))
    end
  end
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def children
  @children
end

#detailObject (readonly)

Returns the value of attribute detail.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def detail
  @detail
end

#endpointsObject (readonly)

Returns the value of attribute endpoints.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def endpoints
  @endpoints
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def path
  @path
end

#publicObject (readonly)

Returns the value of attribute public.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def public
  @public
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/grape_docs/api.rb', line 3

def url
  @url
end