Class: Jat::Plugins::JsonApiValidateParams::ValidateFieldsParam

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, full_map) ⇒ ValidateFieldsParam

Returns a new instance of ValidateFieldsParam.



17
18
19
20
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb', line 17

def initialize(type, full_map)
  @type = type
  @full_map = full_map
end

Instance Attribute Details

#full_mapObject (readonly)

Returns the value of attribute full_map.



15
16
17
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb', line 15

def full_map
  @full_map
end

#typeObject (readonly)

Returns the value of attribute type.



15
16
17
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb', line 15

def type
  @type
end

Class Method Details

.call(jat_class, fields) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb', line 7

def self.call(jat_class, fields)
  full_map = jat_class.map_full

  fields.each do |type, attributes_names|
    new(type, full_map).validate(attributes_names)
  end
end

Instance Method Details

#validate(attributes_names) ⇒ Object



22
23
24
25
# File 'lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb', line 22

def validate(attributes_names)
  check_fields_type
  check_attributes_names(attributes_names)
end