Class: ApipieDSL::ReturnDescription::ReturnObject

Inherits:
Object
  • Object
show all
Includes:
Base, Parameter
Defined in:
lib/apipie_dsl/return_description.rb

Constant Summary

Constants included from Parameter

Parameter::SUPPORTED_TYPES

Instance Method Summary collapse

Methods included from Parameter

#block, #define_param_group, #keyword, #kwlist, #list, #optional, #param, #param_group, #required

Methods included from Base

#apipie_eval_dsl, #dsl_data, #dsl_data_clear

Constructor Details

#initialize(method_description, options, block) ⇒ ReturnObject

Returns a new instance of ReturnObject.



9
10
11
12
13
14
15
# File 'lib/apipie_dsl/return_description.rb', line 9

def initialize(method_description, options, block)
  @method_description = method_description
  @scope = options[:scope]
  @param_group = { scope: @scope }
  @options = options
  @return_type = (@options.keys & %i[array_of one_of object_of param_group]).first
end

Instance Method Details

#default_param_group_scopeObject

this routine overrides Param#default_param_group_scope and is called if Param#param_group is invoked during the instance_exec call in ReturnObject#initialize



20
21
22
# File 'lib/apipie_dsl/return_description.rb', line 20

def default_param_group_scope
  @scope
end

#docs(lang = nil) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/apipie_dsl/return_description.rb', line 35

def docs(lang = nil)
  {
    meta: @return_type,
    class: return_class,
    data: @options[@return_type]
  }
end

#return_classObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/apipie_dsl/return_description.rb', line 24

def return_class
  case @return_type
  when :object_of
    @options[@return_type]
  when :one_of, :param_group
    Object
  when :array_of
    Array
  end
end