module Daitai::Filter

Public Instance Methods

filter() click to toggle source
# File lib/daitai/functions/filter.rb, line 5
def filter
  lambda do |predicate, filterable|
    case filterable
    when Hash then hash_filter(predicate, filterable)
    else default_filter(predicate, filterable)
    end
  end.curry
end

Private Instance Methods

default_filter(predicate, filterable) click to toggle source
# File lib/daitai/functions/filter.rb, line 20
def default_filter(predicate, filterable)
  filterable.select(&predicate)
end
hash_filter(predicate, filterable) click to toggle source
# File lib/daitai/functions/filter.rb, line 16
def hash_filter(predicate, filterable)
  Hash[filterable.select { |_, value| predicate.(value) }]
end