Class: BBK::App::Matchers::Full

Inherits:
Base
  • Object
show all
Defined in:
lib/bbk/app/matchers/full.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(*args) ⇒ Full

Returns a new instance of Full.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bbk/app/matchers/full.rb', line 10

def initialize(*args)
  if args.size == 1
    arg = args[0]
    hrule = arg.fetch(:headers, {})
    prule = arg.fetch(:payload, {})
    drule = arg.fetch(:delivery_info, {})
  else
    hrule, prule, drule = *args
  end

  @hm = Headers.new(hrule)
  @pm = Payload.new(prule)
  @dm = DeliveryInfo.new(drule)
  @rule = [hrule, prule, drule]
end

Instance Method Details

#match(headers, payload, delivery_info, *_args) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/bbk/app/matchers/full.rb', line 26

def match(headers, payload, delivery_info, *_args)
  return unless (hr = @hm.match(headers, payload, delivery_info))
  return unless (pr = @pm.match(headers, payload, delivery_info))
  return unless (dr = @dm.match(headers, payload, delivery_info))

  [hr, pr, dr]
rescue StandardError
  nil
end