Class: Fitting::Response::FullyValidates

Inherits:
Array
  • Object
show all
Defined in:
lib/fitting/response/fully_validates.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.craft(schemas, body, strict) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fitting/response/fully_validates.rb', line 6

def self.craft(schemas, body, strict)
  if schemas
    new(schemas.inject([]) do |res, schema|
      res.push(fully_validate(schema, body, strict))
    end)
  else
    @valid = false
    new
  end
end

.fully_validate(schema, body, strict) ⇒ Object



26
27
28
29
30
# File 'lib/fitting/response/fully_validates.rb', line 26

def fully_validate(schema, body, strict)
  JSON::Validator.fully_validate(schema, body, strict: strict)
rescue JSON::Schema::UriError
  []
end

Instance Method Details

#to_sObject



21
22
23
# File 'lib/fitting/response/fully_validates.rb', line 21

def to_s
  @to_s ||= join("\n\n")
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fitting/response/fully_validates.rb', line 17

def valid?
  @valid ||= any? { |fully_validate| fully_validate == [] }
end