Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using FilterMatcher example
class PeopleMatcher
include FilterMatcher
attr_reader :db
def initialize(db, input)
@db, @input = db, input
end
def match
@input.each do |input|
collection = @db
filter_and_match collection, {
:by_name => input[:name],
:by_age => input[:age],
:by_homepage => input[:homepage]
}
end
end
private
def name_filter(collection, name)
collection.select { |element| element[:name] == name }
end
def age_filter(collection, age)
collection.select { |element| element[:age] == age}
end
def homepage_filter(collection, homepage)
collection.select { |element| element[:homepage] == homepage }
end
def element_matched(element)
element[:matched] = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.