Sha256: 6eb7c7fe3e4517558782adf2db2798dbcf2be8d4de4458cade18a38b7e50e5d0
Contents?: true
Size: 894 Bytes
Versions: 18
Compression:
Stored size: 894 Bytes
Contents
module Origen module Tester module Parser class SearchableArray < ::Array def where(conditions) exact = conditions.delete(:exact) results = SearchableArray.new each do |item| if conditions.all? do |attr, val| if val.is_a?(Array) if exact val.any? { |v| item.send(attr).to_s == v.to_s } else val.any? { |v| item.send(attr).to_s =~ /#{v.to_s}/ } end else if exact item.send(attr).to_s == val.to_s else item.send(attr).to_s =~ /#{val.to_s}/ end end end results << item end end results end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems