Class: PactBroker::Webhooks::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/webhooks/render.rb

Constant Summary collapse

TEMPLATE_PARAMETER_REGEXP =
/\$\{pactbroker\.[^\}]+\}/
DEFAULT_ESCAPER =
lambda { |it| it }

Class Method Summary collapse

Class Method Details

.call(template, params, &escaper) ⇒ Object



17
18
19
# File 'lib/pact_broker/webhooks/render.rb', line 17

def self.call(template, params, &escaper)
  render_template(escape_params(params, escaper || DEFAULT_ESCAPER), template)
end

.includes_parameter?(value) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/pact_broker/webhooks/render.rb', line 9

def self.includes_parameter?(value)
  value =~ TEMPLATE_PARAMETER_REGEXP
end

.render_with_placeholder(value, placeholder = 'placeholder') ⇒ Object



13
14
15
# File 'lib/pact_broker/webhooks/render.rb', line 13

def self.render_with_placeholder(value, placeholder = 'placeholder')
  value.gsub(TEMPLATE_PARAMETER_REGEXP, placeholder)
end