Class: Sbmt::Pact::Matchers::Base
- Inherits:
-
Object
- Object
- Sbmt::Pact::Matchers::Base
- Defined in:
- lib/sbmt/pact/matchers/base.rb
Overview
Direct Known Subclasses
V1::Equality, V2::Regex, V2::Type, V3::Boolean, V3::Date, V3::DateTime, V3::Decimal, V3::Each, V3::Include, V3::Integer, V3::Number, V3::Time, V4::EachKey, V4::EachKeyValue, V4::EachValue, V4::NotEmpty
Defined Under Namespace
Classes: MatcherInitializationError
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#spec_version ⇒ Object
readonly
Returns the value of attribute spec_version.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #as_basic ⇒ Object
- #as_plugin ⇒ Object
-
#initialize(spec_version:, kind:, template:, opts: {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(spec_version:, kind:, template:, opts: {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 |
# File 'lib/sbmt/pact/matchers/base.rb', line 12 def initialize(spec_version:, kind:, template:, opts: {}) @spec_version = spec_version @kind = kind @template = template @opts = opts end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
8 9 10 |
# File 'lib/sbmt/pact/matchers/base.rb', line 8 def kind @kind end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/sbmt/pact/matchers/base.rb', line 8 def opts @opts end |
#spec_version ⇒ Object (readonly)
Returns the value of attribute spec_version.
8 9 10 |
# File 'lib/sbmt/pact/matchers/base.rb', line 8 def spec_version @spec_version end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
8 9 10 |
# File 'lib/sbmt/pact/matchers/base.rb', line 8 def template @template end |
Instance Method Details
#as_basic ⇒ Object
19 20 21 22 23 24 |
# File 'lib/sbmt/pact/matchers/base.rb', line 19 def as_basic { "pact:matcher:type" => serialize!(@kind.deep_dup, :basic), "value" => serialize!(@template.deep_dup, :basic) }.merge(serialize!(@opts.deep_dup, :basic)) end |
#as_plugin ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sbmt/pact/matchers/base.rb', line 26 def as_plugin params = @opts.values.map { |v| format_primitive(v) }.join(",") value = format_primitive(@template) return "matching(#{@kind}, #{params}, #{value})" if params.present? "matching(#{@kind}, #{value})" end |