Class: Schash::Schema::Rule::Type

Inherits:
Base
  • Object
show all
Defined in:
lib/schash/schema/rule/type.rb

Instance Method Summary collapse

Methods inherited from Base

#optional?

Constructor Details

#initialize(klass) ⇒ Type

Returns a new instance of Type.



5
6
7
# File 'lib/schash/schema/rule/type.rb', line 5

def initialize(klass)
  @klass = klass
end

Instance Method Details

#validate(target, position = []) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/schash/schema/rule/type.rb', line 9

def validate(target, position = [])
  errors = []

  unless target.is_a?(@klass)
    errors << Error.new(position, "is not #{@klass}")
  end

  errors
end