Module: Meta::Metadata::ExecutionMethods

Included in:
Meta::Metadata
Defined in:
lib/meta/application/metadata.rb

Instance Method Summary collapse

Instance Method Details

#parse_parameters(execution) ⇒ Object



9
10
11
12
13
# File 'lib/meta/application/metadata.rb', line 9

def parse_parameters(execution)
  parameters.filter(execution.request)
rescue JsonSchema::ValidationErrors => e
  raise Errors::ParameterInvalid.new(e.errors)
end

#parse_request_body(execution, discard_missing: false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/meta/application/metadata.rb', line 15

def parse_request_body(execution, discard_missing: false)
  request_body.filter(
    execution.params(:raw),
    **Meta.config.json_schema_user_options,
    **Meta.config.json_schema_param_stage_user_options,
    **{ execution: execution, stage: :param, scope: @scope, discard_missing: discard_missing }.compact
  )
rescue JsonSchema::ValidationErrors => e
  raise Errors::ParameterInvalid.new(e.errors)
end

#render_entity(execution, entity_schema, value, user_options) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/meta/application/metadata.rb', line 26

def render_entity(execution, entity_schema, value, user_options)
  entity_schema.filter(value,
    **Meta.config.json_schema_user_options,
    **Meta.config.json_schema_render_stage_user_options,
    **{ execution: execution, stage: :render, scope: @scope }.compact,
    **user_options,
  )
end

#set_response(execution) ⇒ Object



35
36
37
38
# File 'lib/meta/application/metadata.rb', line 35

def set_response(execution)
  set_status(execution)
  render_response_body(execution) if self.responses
end