Sha256: 10f8316f2d1630d83dd232e5aec7083355811fb42dcb971b96edf648842260f7
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Filterism class ConditionParser attr_accessor :comparators def initialize @comparators = { 'equal_to' => '=', 'not_equal_to' => '!=', 'greater_than' => '>', 'gt' => '>', 'after' => '>', 'greater_than_or_equal_to' => '>=', 'gtet' => '>=', 'less_than' => '<', 'lt' => '<', 'before' => '<', 'less_than_or_equal_to' => '<=', 'ltet' => '<=', 'like' => 'LIKE', 'in' => 'IN' } end def parse(params) conditions = [] params.each do |key, value| keysplit = key.to_s.split('_is_') if @comparators.keys.include?(keysplit[1]) conditions << { key: keysplit[0], comparator: @comparators[keysplit[1]], value: value } end end return conditions end def add_comparator(comparator) @comparators = @comparators.merge(comparator) end def delete_comparator(comparator_key) @comparators.delete(comparator_key) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
filterism-2.0.0 | lib/filterism/parsers/params_parser.rb |