Module: Qwack::Base

Included in:
BaseArray, BaseEnum, BaseHash, BaseType
Defined in:
lib/qwack/base.rb

Overview

Base module for types

Instance Method Summary collapse

Instance Method Details

#mock(input = nil) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/qwack/base.rb', line 19

def mock(input = nil)
  raise NotImplementedError
end

#mock!(input = nil) ⇒ Object



23
24
25
# File 'lib/qwack/base.rb', line 23

def mock!(input = nil)
  validate!(mock(input))
end

#validate!(input, path = 'root') ⇒ Object



12
13
14
15
16
17
# File 'lib/qwack/base.rb', line 12

def validate!(input, path = 'root')
  errors = validation_errors(input, path)
  raise Qwack::Errors::ValidationError, errors unless errors.empty?

  input
end

#validation_errors(input, path = 'root') ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/qwack/base.rb', line 8

def validation_errors(input, path = 'root')
  raise NotImplementedError
end