Class: Fitting::Records::Unit::JsonSchema
- Inherits:
-
Object
- Object
- Fitting::Records::Unit::JsonSchema
- Defined in:
- lib/fitting/records/unit/json_schema.rb
Instance Method Summary collapse
- #bodies ⇒ Object
-
#initialize(json_schema, tested_bodies) ⇒ JsonSchema
constructor
A new instance of JsonSchema.
Constructor Details
#initialize(json_schema, tested_bodies) ⇒ JsonSchema
Returns a new instance of JsonSchema.
7 8 9 10 |
# File 'lib/fitting/records/unit/json_schema.rb', line 7 def initialize(json_schema, tested_bodies) @json_schema = json_schema @tested_bodies = tested_bodies end |
Instance Method Details
#bodies ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fitting/records/unit/json_schema.rb', line 12 def bodies @bodies ||= @tested_bodies.inject([]) do |res, tested_body| begin next res unless JSON::Validator.validate(@json_schema, tested_body) res.push(tested_body) rescue JSON::Schema::UriError res.push(tested_body) end end end |