Sha256: 81a2071bbc65eb0547a7fcc72dc1bd25c43c32a5c01fcb4da377ff7826e8bdcd

Contents?: true

Size: 461 Bytes

Versions: 3

Compression:

Stored size: 461 Bytes

Contents

module Merit
  class RulesMatcher

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

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

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

    private

    def entire_path
      @entire_path ||= [@path, @action_name].join('#')
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
merit-1.6.2 lib/merit/rules_matcher.rb
merit-1.6.1 lib/merit/rules_matcher.rb
merit-1.6.0 lib/merit/rules_matcher.rb