class ApipieDSL::ExceptionDescription

Attributes

description[R]
error[R]
metadata[R]

Public Class Methods

from_dsl_data(args) click to toggle source
# File lib/apipie_dsl/exception_description.rb, line 6
def self.from_dsl_data(args)
  error_or_options, desc, options = args
  ApipieDSL::ExceptionDescription.new(error_or_options, desc, options)
end
new(error_or_options, desc = nil, options = {}) click to toggle source
# File lib/apipie_dsl/exception_description.rb, line 11
def initialize(error_or_options, desc = nil, options = {})
  if error_or_options.is_a?(Hash)
    error_or_options = error_or_options.transform_keys(&:to_sym)
    @error = error_or_options[:error]
    @metadata = error_or_options[:meta]
    @description = error_or_options[:desc] || error_or_options[:description]
  else
    @error = if error_or_options.is_a?(Symbol)
               Rack::Utils::SYMBOL_TO_STATUS_CODE[error_or_options]
             else
               error_or_options
             end
    raise ArgumentError, error_or_options unless @error

    @metadata = options[:meta]
    @description = desc
  end
end

Public Instance Methods

docs() click to toggle source
# File lib/apipie_dsl/exception_description.rb, line 30
def docs
  {
    error: error,
    description: ApipieDSL.markup_to_html(description),
    metadata: metadata
  }
end