Class: EasyJSONMatcher::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_json_matcher/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = options[:key]
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/easy_json_matcher/validator.rb', line 4

def content
  @content
end

#keyObject (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

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/easy_json_matcher/validator.rb', line 10

def valid?(candidate)
  _set_content(candidate)
  _validate
end