Module: Olyx::Guardrails::PolicyComponents::PatternMatcher

Defined in:
lib/olyx/guardrails/policy/pattern_matcher.rb

Overview

Enumerates private offsets for one compiled policy pattern.

Class Method Summary collapse

Class Method Details

.call(source, rule, index, pattern) ⇒ Object



10
11
12
13
14
15
# File 'lib/olyx/guardrails/policy/pattern_matcher.rb', line 10

def call(source, rule, index, pattern)
  source.to_enum(:scan, pattern).map do
    match = Regexp.last_match
    { rule: rule, rule_index: index, full: match[0].to_s, start: match.begin(0), end: match.end(0) }
  end
end