Class: BBK::App::Matchers::Payload

Inherits:
Base
  • Object
show all
Defined in:
lib/bbk/app/matchers/payload.rb

Instance Attribute Summary

Attributes inherited from Base

#rule

Instance Method Summary collapse

Methods inherited from Base

#==, #eql?, #hash, #keys_deep, #match_impl

Constructor Details

#initialize(rule) ⇒ Payload

Returns a new instance of Payload.



8
9
10
# File 'lib/bbk/app/matchers/payload.rb', line 8

def initialize(rule)
  @rule = rule.with_indifferent_access
end

Instance Method Details

#match(_headers, payload, _delivery_info = nil, *_args) ⇒ Object



12
13
14
15
16
17
# File 'lib/bbk/app/matchers/payload.rb', line 12

def match(_headers, payload, _delivery_info = nil, *_args)
  payload = JSON(payload) if payload&.is_a?(String)
  match_impl(@rule, payload.with_indifferent_access)
rescue StandardError
  nil
end