Class: JSONSkooma::Validators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/json_skooma/validators/base.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.instance_typesObject

Returns the value of attribute instance_types.



7
8
9
# File 'lib/json_skooma/validators/base.rb', line 7

def instance_types
  @instance_types
end

Class Method Details

.assert?(instance) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/json_skooma/validators/base.rb', line 13

def assert?(instance)
  instance_types.include?(instance.type)
end

.call(instance) ⇒ Object



17
18
19
# File 'lib/json_skooma/validators/base.rb', line 17

def call(instance)
  new.call(instance)
end

.inherited(subclass) ⇒ Object



21
22
23
# File 'lib/json_skooma/validators/base.rb', line 21

def inherited(subclass)
  subclass.instance_types = "string"
end

Instance Method Details

#call(_instance) ⇒ Object

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/json_skooma/validators/base.rb', line 26

def call(_instance)
  raise NotImplementedError, "must be implemented by subclass"
end