Class: EasyJSONMatcher::Validator
- Inherits:
-
Object
- Object
- EasyJSONMatcher::Validator
- Defined in:
- lib/easy_json_matcher/validator.rb
Direct Known Subclasses
ArrayValidator, BooleanValidator, DateValidator, Node, NumberValidator, ObjectValidator, StringValidator, ValueValidator
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #_set_content(candidate) ⇒ Object
-
#initialize(options: {}) ⇒ Validator
constructor
A new instance of Validator.
- #valid?(candidate) ⇒ Boolean
Constructor Details
#initialize(options: {}) ⇒ Validator
Returns a new instance of Validator.
6 7 8 |
# File 'lib/easy_json_matcher/validator.rb', line 6 def initialize(options: {}) @key = [:key] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/easy_json_matcher/validator.rb', line 4 def content @content end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/easy_json_matcher/validator.rb', line 4 def key @key end |
Instance Method Details
#_set_content(candidate) ⇒ Object
15 16 17 |
# File 'lib/easy_json_matcher/validator.rb', line 15 def _set_content(candidate) @content = key ? candidate[key.to_s] : candidate end |
#valid?(candidate) ⇒ Boolean
10 11 12 13 |
# File 'lib/easy_json_matcher/validator.rb', line 10 def valid?(candidate) _set_content(candidate) _validate end |