Sha256: d9968cf4d1b61af31675ba2d3e658b9bc289145dce829bc735ddef2c7fbafd38

Contents?: true

Size: 485 Bytes

Versions: 2

Compression:

Stored size: 485 Bytes

Contents

module Merit
  class RulesMatcher

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

    def select_from(rules)
      rules.select do |glob, _|
        entire_path =~ /^#{Regexp.new(glob)}$/
      end.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

2 entries across 2 versions & 1 rubygems

Version Path
merit-1.7.1 lib/merit/rules_matcher.rb
merit-1.7.0 lib/merit/rules_matcher.rb