Class: Merit::RulesMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/merit/rules_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, action_name) ⇒ RulesMatcher

Returns a new instance of RulesMatcher.



3
4
5
6
# File 'lib/merit/rules_matcher.rb', line 3

def initialize(path, action_name)
  @path = path
  @action_name = action_name
end

Instance Method Details

#any_matching?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/merit/rules_matcher.rb', line 14

def any_matching?
  select_from(AppBadgeRules).any? || select_from(AppPointRules).any?
end

#select_from(rules) ⇒ Object



8
9
10
11
12
# File 'lib/merit/rules_matcher.rb', line 8

def select_from(rules)
  rules.select do |glob, _|
    entire_path =~ /^#{Regexp.new(glob)}$/
  end.values.flatten
end