Class: Skooma::Objects::Header::Keywords::Content
- Inherits:
-
JSONSkooma::Keywords::Base
- Object
- JSONSkooma::Keywords::Base
- Skooma::Objects::Header::Keywords::Content
show all
- Defined in:
- lib/skooma/objects/header/keywords/content.rb
Instance Method Summary
collapse
Instance Method Details
#evaluate(instance, result) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/skooma/objects/header/keywords/content.rb', line 12
def evaluate(instance, result)
return if instance&.value.nil?
media_type = result.root.instance["response"]["headers"]["Content-Type"]&.split(";")&.first&.strip&.downcase
media_type_object, matched_media_type = find_media_type(media_type)
return result.discard unless media_type_object
result.annotate(matched_media_type)
result.call(instance, matched_media_type) do |media_type_result|
media_type_object.evaluate(instance, media_type_result)
result.failure("Invalid content") unless media_type_result.passed?
end
end
|