Module: Textus::Protocol::Key::Matching
- Defined in:
- lib/textus/protocol/key/matching.rb
Class Method Summary collapse
Class Method Details
.match?(pattern, key) ⇒ Boolean
13 14 15 16 17 18 19 |
# File 'lib/textus/protocol/key/matching.rb', line 13 def match?(pattern, key) segs = pattern.split(".") key_segs = key.split(".") return false if segs.length != key_segs.length segs.zip(key_segs).all? { |p, k| p == "*" || p == k } end |
.matches_prefix?(key, prefix, nested: false) ⇒ Boolean
7 8 9 10 11 |
# File 'lib/textus/protocol/key/matching.rb', line 7 def matches_prefix?(key, prefix, nested: false) return true if key == prefix || key.start_with?("#{prefix}.") nested && prefix.start_with?("#{key}.") end |