Class: GrapeDocs::Endpoint

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, endpoint) ⇒ Endpoint

Returns a new instance of Endpoint.



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

def initialize(api, endpoint)
  options = endpoint.options[:route_options]
  @title = options[:description] || endpoint.options[:path].first
  @detail = options[:detail]
  parent_path = File.join(endpoint.inheritable_setting.namespace_stackable[:mount_path])
  @path = File.join(parent_path, endpoint.options[:path].first.to_s)
  @url = File.join(GrapeDocs.config[:api_host], @path)
  @params = options[:params].map { |p| p[1].merge(name: p[0]) }
  @method = endpoint.options[:method].first
  if options[:entity]
    @model = options[:entity].documentation.map { |p| p[1].merge(name: p[0]) }
    @response = build_response(@model)
  end
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



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

def detail
  @detail
end

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#modelObject (readonly)

Returns the value of attribute model.



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

def model
  @model
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end