Sha256: ae1c7d4234ccc82ecab9ac5b131763404b80e003f8bc4fa22ea185aab69293f7
Contents?: true
Size: 742 Bytes
Versions: 2
Compression:
Stored size: 742 Bytes
Contents
require 'pact_broker/webhooks/pact_and_verification_parameters' module PactBroker module Webhooks class Render TEMPLATE_PARAMETER_REGEXP = /\$\{pactbroker\.[^\}]+\}/ DEFAULT_ESCAPER = lambda { |it| it } def self.call(template, params, &escaper) render_template(escape_params(params, escaper || DEFAULT_ESCAPER), template) end def self.render_template(params, template) params.inject(template) do | template, (key, value) | template.gsub(key, value) end end def self.escape_params(params, escaper) params.keys.each_with_object({}) do | key, new_params | new_params[key] = escaper.call(params[key]) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pact_broker-2.34.0 | lib/pact_broker/webhooks/render.rb |
pact_broker-2.33.0 | lib/pact_broker/webhooks/render.rb |