Module: Placet::ActionMatch

Defined in:
lib/placet/engine.rb

Overview

action パターンのマッチング(concept.md 3.3: セグメント単位で literal か *)

Class Method Summary collapse

Class Method Details

.match?(pattern, action) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/placet/engine.rb', line 8

def self.match?(pattern, action)
  return true if pattern == "*"

  p_res, p_op = pattern.split(":", 2)
  a_res, a_op = action.split(":", 2)
  (p_res == "*" || p_res == a_res) && (p_op == "*" || p_op == a_op)
end