Class: Jat::Plugins::JsonApiValidateParams::ValidateIncludeParam

Inherits:
Object
  • Object
show all
Defined in:
lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_include_param.rb

Class Method Summary collapse

Class Method Details

.call(jat_class, includes) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_include_param.rb', line 8

def call(jat_class, includes)
  includes.each do |name, nested_includes|
    attribute = jat_class.attributes[name]
    raise_error(jat_class, name) if !attribute || !attribute.relation?

    nested_serializer = attribute.serializer.call
    call(nested_serializer, nested_includes)
  end
end