class Grape::App::Doc::Entity
Constants
- LegacyExposure
Attributes
attributes[R]
desc[R]
name[R]
uid[R]
Public Class Methods
new(klass, registry)
click to toggle source
# File lib/grape/app/doc/entity.rb, line 4 def initialize(klass, registry) @name = (klass.meta[:type] if klass.respond_to?(:meta)) || klass.name.gsub('::Entity', '') @desc = (klass.meta[:desc] || klass.meta[:description] if klass.respond_to?(:meta)) || "" @uid = [name.parameterize, Grape::App::Doc.next_increment!].join('-') exposures = klass.root_exposures exposures = exposures.map do |key, opts| LegacyExposure.new(key, opts[:using], opts[:documentation]) end if klass.root_exposures.is_a?(Hash) @attributes = exposures.map do |exp| doc = exp.documentation.try(:dup) unless doc.is_a?(Hash) Grape::App::Doc.doc_error("#{klass}: #{name} exposure does not have documentation") next end unless doc.key?(:type) Grape::App::Doc.doc_error("#{klass}: #{name} exposure does not have :type documentation") next end if exp.respond_to?(:using_class) && exp.using_class registry.register(exp.using_class) end Grape::App::Doc::Attribute.new(exp.key, doc) end.compact end
Public Instance Methods
example()
click to toggle source
# File lib/grape/app/doc/entity.rb, line 31 def example @example ||= attributes.inject({}) do |acc, attr| acc[attr.key] = attr.type acc end end