- IS_TRUE =
Operator.new(:is_true,
_('is set'),
proc { |x| x })
- IS_NOT_TRUE =
Operator.new(:is_not_true,
_('is not set'),
proc { |x| !x })
- IS =
Operator.new(:is,
_('is'),
proc { |x, y| x == y })
- IS_NOT =
Operator.new(:is_not,
_('is not'),
proc { |x, y| x != y })
- CONTAINS =
Operator.new(:contains,
_('contains'),
proc { |x, y| x.include?(y) })
- DOES_NOT_CONTAIN =
Operator.new(:does_not_contain,
_('does not contain'),
proc { |x, y| !x.include?(y) })
- STARTS_WITH =
Operator.new(:starts_with,
_('starts with'),
proc { |x, y| /^#{y}/.match(x) })
- ENDS_WITH =
Operator.new(:ends_with,
_('ends with'),
proc { |x, y| /#{y}$/.match(x) })
- IS_GREATER_THAN =
Operator.new(:is_greater_than,
_('is greater than'),
proc { |x, y| x > y })
- IS_LESS_THAN =
Operator.new(:is_less_than,
_('is less than'),
proc { |x, y| x < y })
- IS_AFTER =
Operator.new(:is_after,
_('is after'),
proc { |x, y| x.to_i > y.to_i && !x.nil? })
- IS_BEFORE =
Operator.new(:is_before,
_('is before'),
proc { |x, y| x.to_i < y.to_i && !x.nil? })
- IS_IN_LAST =
Operator.new(:is_in_last_days,
_('is in last'),
proc { |x, y|
begin
if x.nil? || x.empty?
false
else
log.debug { "Given Date: #{x.inspect} #{x.class}" }
given_date = Time.parse(x)
days = y.to_i * (24 * 60 * 60)
Time.now - given_date <= days
end
rescue => ex
trace = ex.backtrace.join("\n >")
log.warn { "Date matching failed #{ex} #{trace}" }
false
end
})
- IS_NOT_IN_LAST =
Operator.new(:is_not_in_last_days,
_('is not in last'),
proc { |x, y|
begin
if x.nil? || x.empty?
false
else
log.debug { "Given Date: #{x.inspect} #{x.class}" }
given_date = Time.parse(x)
days = y.to_i * (24 * 60 * 60)
Time.now - given_date > days
end
rescue => ex
trace = ex.backtrace.join("\n >")
log.warn { "Date matching failed #{ex} #{trace}" }
false
end
})
- ALL =
constants.map \
{ |x| module_eval(x.to_s) }.select \
{ |x| x.is_a?(Operator) }