class ActiveHash::Matcher::Or

Attributes

patterns[RW]

Public Class Methods

new(patterns) click to toggle source
# File lib/active_hash/matcher/or.rb, line 5
def initialize(patterns)
  self.patterns = patterns
end

Public Instance Methods

call(record) click to toggle source
# File lib/active_hash/matcher/or.rb, line 9
def call(record)
  patterns.any? do |col, matcher|
    if matcher.respond_to?(:call)
      matcher.call(record[col])
    elsif col.to_sym == :or
      ActiveHash::Matcher::Or.new(matcher).call(record)
    else
      record[col] == matcher
    end
  end
end