Class: HashSchema::Schema
- Inherits:
-
Object
- Object
- HashSchema::Schema
- Defined in:
- lib/hash_schema.rb
Direct Known Subclasses
ArraySchema, BooleanSchema, EnumSchema, HashSchema, NumberSchema, OptionalSchema, OrSchema, StringSchema
Instance Attribute Summary collapse
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
Instance Method Summary collapse
- #expectation ⇒ Object
-
#initialize(chain = nil) ⇒ Schema
constructor
A new instance of Schema.
- #interpret(data) ⇒ Object
- #pretty_validate(data) ⇒ Object
Constructor Details
#initialize(chain = nil) ⇒ Schema
Returns a new instance of Schema.
5 6 7 |
# File 'lib/hash_schema.rb', line 5 def initialize(chain = nil) @chain = chain end |
Instance Attribute Details
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
15 16 17 |
# File 'lib/hash_schema.rb', line 15 def chain @chain end |
Instance Method Details
#expectation ⇒ Object
22 23 24 |
# File 'lib/hash_schema.rb', line 22 def expectation self.class.name.split('::').last.sub('Schema', '') end |
#interpret(data) ⇒ Object
9 10 11 12 13 |
# File 'lib/hash_schema.rb', line 9 def interpret(data) (@interpretations = []).tap do |_| interpret_errors(validate(data), 'root') end end |
#pretty_validate(data) ⇒ Object
17 18 19 20 |
# File 'lib/hash_schema.rb', line 17 def pretty_validate(data) require 'json' JSON.pretty_generate(validate(data)) end |