Class: Apipie::ResponseDescription::ResponseObject
- Inherits:
-
Object
- Object
- Apipie::ResponseDescription::ResponseObject
- Includes:
- DSL::Base, DSL::Param
- Defined in:
- lib/apipie/response_description.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
Returns the value of attribute additional_properties.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#typename ⇒ Object
Returns the value of attribute typename.
Attributes included from DSL::Base
#api_params, #apipie_resource_descriptions
Instance Method Summary collapse
-
#_default_param_group_scope ⇒ Object
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.
- #header(header_name, validator, description, options = {}) ⇒ Object
-
#initialize(method_description, scope, block, typename) ⇒ ResponseObject
constructor
A new instance of ResponseObject.
- #name ⇒ Object
- #params_ordered ⇒ Object
- #prepare_hash_params ⇒ Object
Methods included from DSL::Param
#param, #param_group, #property, #returns
Methods included from DSL::Base
Constructor Details
#initialize(method_description, scope, block, typename) ⇒ ResponseObject
Returns a new instance of ResponseObject.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/apipie/response_description.rb', line 11 def initialize(method_description, scope, block, typename) @method_description = method_description @scope = scope @param_group = {scope: scope} @additional_properties = false @typename = typename @headers = [] self.instance_exec(&block) if block prepare_hash_params end |
Instance Attribute Details
#additional_properties ⇒ Object
Returns the value of attribute additional_properties.
8 9 10 |
# File 'lib/apipie/response_description.rb', line 8 def additional_properties @additional_properties end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/apipie/response_description.rb', line 9 def headers @headers end |
#typename ⇒ Object
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_scope ⇒ Object
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
26 27 28 |
# File 'lib/apipie/response_description.rb', line 26 def _default_param_group_scope @scope end |
#header(header_name, validator, description, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/apipie/response_description.rb', line 52 def header(header_name, validator, description, = {}) @headers << { name: header_name, validator: validator.to_s.downcase, description: description, options: } end |
#name ⇒ Object
30 31 32 |
# File 'lib/apipie/response_description.rb', line 30 def name "response #{@code} for #{@method_description.method}" end |
#params_ordered ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/apipie/response_description.rb', line 34 def params_ordered @params_ordered ||= _apipie_dsl_data[:params].map do |args| = args.find { |arg| arg.is_a? Hash } [:param_group] = @param_group Apipie::ParamDescription.from_dsl_data(@method_description, args) unless [:only_in] == :request end.compact end |
#prepare_hash_params ⇒ Object
42 43 44 45 46 |
# File 'lib/apipie/response_description.rb', line 42 def prepare_hash_params @hash_params = params_ordered.reduce({}) do |h, param| h.update(param.name.to_sym => param) end end |