Class: JsonExpressions::Matcher
- Inherits:
-
Object
- Object
- JsonExpressions::Matcher
- Defined in:
- lib/json_expressions/matcher.rb
Class Attribute Summary collapse
-
.assume_strict_arrays ⇒ Object
JsonExpressions::Matcher.assume_strict_arrays (Boolean) By default, reject arrays with extra elements when not specified Default: true.
-
.assume_strict_hashes ⇒ Object
JsonExpressions::Matcher.assume_strict_hashes (Boolean) By default, reject hashes with extra keys when not specified Default: true.
-
.assume_unordered_arrays ⇒ Object
JsonExpressions::Matcher.assume_unordered_arrays (Boolean) By default, assume arrays are unordered when not specified Default: true.
-
.assume_unordered_hashes ⇒ Object
JsonExpressions::Matcher.assume_unordered_hashes (Boolean) By default, assume hashes are unordered when not specified Default: true.
-
.skip_triple_equal_on ⇒ Object
JsonExpressions::Matcher.skip_triple_equal_on (Array) An array of classes and modules with undesirable ‘===` behavior Default: [].
Instance Attribute Summary collapse
-
#captures ⇒ Object
readonly
Returns the value of attribute captures.
-
#last_error ⇒ Object
readonly
Returns the value of attribute last_error.
Instance Method Summary collapse
- #=~(other) ⇒ Object
-
#initialize(json, options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #match(other) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(json, options = {}) ⇒ Matcher
Returns a new instance of Matcher.
41 42 43 44 45 46 |
# File 'lib/json_expressions/matcher.rb', line 41 def initialize(json, = {}) defaults = {} @json = json @options = defaults.merge() reset! end |
Class Attribute Details
.assume_strict_arrays ⇒ Object
JsonExpressions::Matcher.assume_strict_arrays (Boolean)
By default, reject arrays with extra elements when not specified
Default: true
22 23 24 |
# File 'lib/json_expressions/matcher.rb', line 22 def assume_strict_arrays @assume_strict_arrays end |
.assume_strict_hashes ⇒ Object
JsonExpressions::Matcher.assume_strict_hashes (Boolean)
By default, reject hashes with extra keys when not specified
Default: true
34 35 36 |
# File 'lib/json_expressions/matcher.rb', line 34 def assume_strict_hashes @assume_strict_hashes end |
.assume_unordered_arrays ⇒ Object
JsonExpressions::Matcher.assume_unordered_arrays (Boolean)
By default, assume arrays are unordered when not specified
Default: true
16 17 18 |
# File 'lib/json_expressions/matcher.rb', line 16 def assume_unordered_arrays @assume_unordered_arrays end |
.assume_unordered_hashes ⇒ Object
JsonExpressions::Matcher.assume_unordered_hashes (Boolean)
By default, assume hashes are unordered when not specified
Default: true
28 29 30 |
# File 'lib/json_expressions/matcher.rb', line 28 def assume_unordered_hashes @assume_unordered_hashes end |
.skip_triple_equal_on ⇒ Object
JsonExpressions::Matcher.skip_triple_equal_on (Array)
An array of classes and modules with undesirable `===` behavior
Default: []
10 11 12 |
# File 'lib/json_expressions/matcher.rb', line 10 def skip_triple_equal_on @skip_triple_equal_on end |
Instance Attribute Details
#captures ⇒ Object (readonly)
Returns the value of attribute captures.
39 40 41 |
# File 'lib/json_expressions/matcher.rb', line 39 def captures @captures end |
#last_error ⇒ Object (readonly)
Returns the value of attribute last_error.
38 39 40 |
# File 'lib/json_expressions/matcher.rb', line 38 def last_error @last_error end |
Instance Method Details
#=~(other) ⇒ Object
48 49 50 51 |
# File 'lib/json_expressions/matcher.rb', line 48 def =~(other) reset! match_json('(JSON ROOT)', @json, other) end |
#match(other) ⇒ Object
53 54 55 |
# File 'lib/json_expressions/matcher.rb', line 53 def match(other) self =~ other end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/json_expressions/matcher.rb', line 57 def to_s @json.to_s end |