Sha256: 9cbfbc22f0cb75ee27b73f138572ae4ce1380c993efe3b96bda9e93c8d1e15fc

Contents?: true

Size: 981 Bytes

Versions: 22

Compression:

Stored size: 981 Bytes

Contents

require 'bbk/app/matchers/base'

module BBK
  module App
    module Matchers
      class DeliveryInfo < Base


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

        def match(_headers, _payload, delivery_info, *_args)
          delivery_info = delivery_info.to_hash unless delivery_info.is_a? Hash
          match_impl(@rule, delivery_info.with_indifferent_access)
        rescue StandardError
          nil
        end

        def match_impl(rule, data)
          result = super
          if !result && (key_rule = rule[:routing_key])
            regexp_rule = Regexp.new("\\A#{key_rule.gsub('.', '\.').gsub('*', '\S+').gsub('#',
                                                                                          '.*')}\\Z")
            check = regexp_rule.match?(data[:routing_key])
            result = ({ 'routing_key' => data[:routing_key] } if check)
          end
          result
        end

      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bbk-app-1.1.1.273627 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.1.273338 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.1.273312 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.1.273294 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.219406 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.216998 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.204569 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.200751 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.200186 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.199675 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.199604 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.199389 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.1.0.199383 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.152254 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.141716 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.80957 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.79514 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.79241 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.78020 lib/bbk/app/matchers/delivery_info.rb
bbk-app-1.0.0.72920 lib/bbk/app/matchers/delivery_info.rb