Skip to content
Kward Search API index

Class: Kward::Hooks::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/hooks/matcher.rb

Overview

Matches lifecycle hook selectors against event payloads.

Instance Method Summary collapse

Constructor Details

#initialize(match = nil) ⇒ Matcher

Returns a new instance of Matcher.



6
7
8
# File 'lib/kward/hooks/matcher.rb', line 6

def initialize(match = nil)
  @match = match || {}
end

Instance Method Details

#match?(event) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/kward/hooks/matcher.rb', line 10

def match?(event)
  return true if @match.empty?

  @match.all? { |key, expected| matches_key?(event, key.to_s, expected) }
end