class Rounders::Matchers::Matcher
Attributes
matchers[R]
Public Class Methods
build(conditions)
click to toggle source
# File lib/rounders/matchers/matcher.rb, line 30 def build(conditions) matchers = conditions.map do |key, pattern| matcher = Rounders.matchers[key] raise Rounders::Matchers::NoImplementError if matcher.nil? matcher.new(pattern) end new(matchers) rescue StandardError => e raise e end
inherited(klass)
click to toggle source
Calls superclass method
# File lib/rounders/matchers/matcher.rb, line 25 def inherited(klass) super Rounders.matchers[klass.symbol] = klass end
new(matchers)
click to toggle source
# File lib/rounders/matchers/matcher.rb, line 12 def initialize(matchers) @matchers = matchers end
Public Instance Methods
match(message)
click to toggle source
# File lib/rounders/matchers/matcher.rb, line 16 def match(message) match_data = matchers.each_with_object({}) do |matcher, memo| memo[matcher.class.symbol] = matcher.match(message) end return match_data if match_data.values.none? { |value| Util.blank?(value) } nil end