Class: HashSchema::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#chainObject (readonly)

Returns the value of attribute chain.



15
16
17
# File 'lib/hash_schema.rb', line 15

def chain
  @chain
end

Instance Method Details

#expectationObject



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