Class: Schash::Schema::Rule::Type
- Defined in:
- lib/schash/schema/rule/type.rb
Instance Method Summary collapse
-
#initialize(klass) ⇒ Type
constructor
A new instance of Type.
- #validate(target, position = []) ⇒ Object
Methods inherited from Base
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 |