allow the datetime comparaison with nil values
Didier Lafforgue
committed May 10, 2018
commit f8d9607cd23011caa613982c6f6c7fd22fc2c562
Showing 2
changed files with
6 additions
and 5 deletions
locomotive/steam/adapters/memory/condition.rb b/lib/locomotive/steam/adapters/memory/condition.rb
+5
-4
| @@ | @@ -22,16 +22,17 @@ module Locomotive::Steam |
| entry_value = entry_value(entry) | |
| adapt_operator!(entry_value) | |
| + | |
| case @operator | |
| when :== then entry_value == @value | |
| when :eq then entry_value == @value | |
| when :ne then entry_value != @value | |
| when :neq then entry_value != @value | |
| when :matches then @value =~ entry_value | |
| - | when :gt then entry_value > @value |
| - | when :gte then entry_value >= @value |
| - | when :lt then entry_value < @value |
| - | when :lte then entry_value <= @value |
| + | when :gt then entry_value && entry_value > @value |
| + | when :gte then entry_value && entry_value >= @value |
| + | when :lt then entry_value && entry_value < @value |
| + | when :lte then entry_value && entry_value <= @value |
| when :size then entry_value.size == @value | |
| when :all then array_contains?([*@value], entry_value) | |
| when :in, :nin then value_is_in_entry_value?(entry_value) | |
locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb
+1
-1
| @@ | @@ -287,7 +287,7 @@ module Locomotive |
| else | |
| value | |
| end | |
| - | type == :date ? _value.to_date : _value.to_datetime |
| + | type == :date ? _value&.to_date : _value&.to_datetime |
| end | |
| end | |