Sha256: 2bd836fe0d3d4561fc836d2b8c30622fdc63c2262cd53d337813b6a9d378e869
Contents?: true
Size: 1.06 KB
Versions: 10
Compression:
Stored size: 1.06 KB
Contents
module CloudSesame module Query module DSL module AppliedFilterQuery def included?(field, value = nil) !!( (field_options = _context[:fields][field.to_sym]) && (applied = field_options[:applied]) && ( (!value && applied.values.any?) || ( value && (index = applied.keys.index(value)) && (field_options[:applied].values[index] != false) ) ) ) end def excluded?(field, value = nil) !!( (field_options = _context[:fields][field.to_sym]) && (applied = field_options[:applied]) && ( (!value && !applied.values.all?) || ( value && (index = applied.keys.index(value)) && field_options[:applied].values[index] == false ) ) ) end def applied_filters applied = {} _context[:fields].each do |field, options| if options && options[:applied] && !(values = options[:applied].select { |k, v| v }.keys).empty? applied[field] = values end end applied end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems