Class: Pact::Generator::Regex

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/generator/regex.rb

Overview

Regex provides the regex generator which will generate a value based on the regex pattern provided

Instance Method Summary collapse

Instance Method Details

#call(hash, _params = nil, _example_value = nil) ⇒ Object



11
12
13
14
# File 'lib/pact/generator/regex.rb', line 11

def call(hash, _params = nil, _example_value = nil)
  pattern = hash['pattern'] || ''
  StringPattern.generate(Regexp.new(pattern))
end

#can_generate?(hash) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/pact/generator/regex.rb', line 7

def can_generate?(hash)
  hash.key?('type') && hash['type'] == 'Regex'
end