Class: Kward::Hooks::Matcher
- Inherits:
-
Object
- Object
- Kward::Hooks::Matcher
- Defined in:
- lib/kward/hooks/matcher.rb
Overview
Matches lifecycle hook selectors against event payloads.
Instance Method Summary collapse
-
#initialize(match = nil) ⇒ Matcher
constructor
A new instance of Matcher.
- #match?(event) ⇒ Boolean
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
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 |