Class: Shogun::Verifier::Match
- Inherits:
-
Object
- Object
- Shogun::Verifier::Match
- Defined in:
- lib/shogun/verifier/match.rb
Instance Method Summary collapse
- #context ⇒ Object
- #id ⇒ Object
-
#initialize(data:, name:, comparison:) ⇒ Match
constructor
A new instance of Match.
- #valid? ⇒ Boolean
Constructor Details
#initialize(data:, name:, comparison:) ⇒ Match
Returns a new instance of Match.
4 5 6 7 8 |
# File 'lib/shogun/verifier/match.rb', line 4 def initialize(data:, name:, comparison:) @data = data @name = name @comparison = comparison end |
Instance Method Details
#context ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/shogun/verifier/match.rb', line 22 def context if @comparison.is_a?(Regexp) { "pattern" => @comparison } end end |
#id ⇒ Object
18 19 20 |
# File 'lib/shogun/verifier/match.rb', line 18 def id "#{@name}_does_not_match" end |
#valid? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/shogun/verifier/match.rb', line 10 def valid? if @comparison.is_a?(Regexp) @data =~ @comparison else @data == @comparison || @comparison == @data end end |