Module: MWO::CollectionUtils

Defined in:
lib/mwo/collection_utils.rb

Instance Method Summary collapse

Instance Method Details

#filter(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/mwo/collection_utils.rb', line 2

def filter(options = {})
  filtered = self.find_all do |element|
    matches = options.find_all do |k,v|
      element.send(k) == options[k]
    end
    !matches.empty?
  end

  filtered
end