Class: Apipie::ResponseDescription::ResponseObject

Inherits:
Object
  • Object
show all
Includes:
DSL::Base, DSL::Param
Defined in:
lib/apipie/response_description.rb

Instance Attribute Summary collapse

Attributes included from DSL::Base

#api_params, #apipie_resource_descriptions

Instance Method Summary collapse

Methods included from DSL::Param

#param, #param_group, #property, #returns

Methods included from DSL::Base

#_apipie_eval_dsl

Constructor Details

#initialize(method_description, scope, block, typename) ⇒ ResponseObject

Returns a new instance of ResponseObject.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/apipie/response_description.rb', line 10

def initialize(method_description, scope, block, typename)
  @method_description = method_description
  @scope = scope
  @param_group = {scope: scope}
  @additional_properties = false
  @typename = typename

  self.instance_exec(&block) if block

  prepare_hash_params
end

Instance Attribute Details

#additional_propertiesObject

Returns the value of attribute additional_properties.



8
9
10
# File 'lib/apipie/response_description.rb', line 8

def additional_properties
  @additional_properties
end

#typenameObject

Returns the value of attribute typename.



8
9
10
# File 'lib/apipie/response_description.rb', line 8

def typename
  @typename
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 ResponseObject#initialize



24
25
26
# File 'lib/apipie/response_description.rb', line 24

def _default_param_group_scope
  @scope
end

#nameObject



28
29
30
# File 'lib/apipie/response_description.rb', line 28

def name
  "response #{@code} for #{@method_description.method}"
end

#params_orderedObject



32
33
34
35
36
37
38
# File 'lib/apipie/response_description.rb', line 32

def params_ordered
  @params_ordered ||= _apipie_dsl_data[:params].map do |args|
    options = args.find { |arg| arg.is_a? Hash }
    options[:param_group] = @param_group
    Apipie::ParamDescription.from_dsl_data(@method_description, args) unless options[:only_in] == :request
  end.compact
end

#prepare_hash_paramsObject



40
41
42
43
44
# File 'lib/apipie/response_description.rb', line 40

def prepare_hash_params
  @hash_params = params_ordered.reduce({}) do |h, param|
    h.update(param.name.to_sym => param)
  end
end