Class: Restspec::Schema::Checker
- Inherits:
-
Struct
- Object
- Struct
- Restspec::Schema::Checker
- Defined in:
- lib/restspec/schema/checker.rb
Defined Under Namespace
Classes: DifferentTypeError, NoAttributeError, NoObjectError, ObjectChecker
Instance Attribute Summary collapse
-
#schema ⇒ Object
Returns the value of attribute schema.
Instance Method Summary collapse
Instance Attribute Details
#schema ⇒ Object
Returns the value of attribute schema
3 4 5 |
# File 'lib/restspec/schema/checker.rb', line 3 def schema @schema end |
Instance Method Details
#check!(object) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/restspec/schema/checker.rb', line 8 def check!(object) raise NoObjectError.new(object) unless object.is_a?(Hash) schema.attributes.each do |_, attribute| if attribute.can_be_checked? checker = ObjectChecker.new(object, attribute) raise NoAttributeError.new(object, attribute) if checker.missed_key? raise DifferentTypeError.new(object, attribute) if checker.wrong_type? end end end |
#check_array!(array) ⇒ Object
4 5 6 |
# File 'lib/restspec/schema/checker.rb', line 4 def check_array!(array) array.each { |item| check!(item) } end |