module Jekyll::Filters
def where(input, property, value)
their `#inspect` string object.
Cannot be an instance of Array nor Hash since calling #to_s on them returns
value - the desired value.
property - the property within each object to filter by.
input - the object array.
Filter an array of objects
def where(input, property, value) return input if !property || value.is_a?(Array) || value.is_a?(Hash) return input unless input.respond_to?(:select) input = input.values if input.is_a?(Hash) input_id = input.hash # implement a hash based on method parameters to cache the end-result # for given parameters. @where_filter_cache ||= {} @where_filter_cache[input_id] ||= {} @where_filter_cache[input_id][property] ||= {} # stash or retrieve results to return @where_filter_cache[input_id][property][value] ||= input.select do |object| compare_property_vs_target(item_property(object, property), value) end.to_a end