Class: Pact::V2::Matchers::V3::ContentType

Inherits:
Base
  • Object
show all
Defined in:
lib/pact/v2/matchers/v3/content_type.rb

Instance Attribute Summary

Attributes inherited from Base

#kind, #opts, #spec_version, #template

Instance Method Summary collapse

Methods inherited from Base

#as_basic

Constructor Details

#initialize(content_type, template: nil) ⇒ ContentType

Returns a new instance of ContentType.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pact/v2/matchers/v3/content_type.rb', line 8

def initialize(content_type, template: nil)
  @content_type = content_type
  @template = template
  @opts = {}
  @opts[:plugin_template] = template unless template.nil?
  unless content_type.is_a?(String) && !content_type.empty?
    raise MatcherInitializationError, "#{self.class}: content_type must be a non-empty String"
  end

  super(
    spec_version: Pact::V2::Matchers::PACT_SPEC_V3,
    kind: "contentType",
    template: content_type,
    opts: @opts
  )
end

Instance Method Details

#as_pluginObject



25
26
27
# File 'lib/pact/v2/matchers/v3/content_type.rb', line 25

def as_plugin
  "matching(contentType, '#{@content_type}', '#{@opts[:plugin_template]}')"
end