1
0
Fork 0

Cast comparisons

Dieser Commit ist enthalten in:
Angus McLeod 2020-04-07 21:53:00 +10:00
Ursprung 565e175f79
Commit 06e618ecbe
2 geänderte Dateien mit 29 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -155,6 +155,16 @@
color: $primary; color: $primary;
} }
} }
.select-kit-header .selected-name {
max-width: 85%;
.name {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
} }
.mapper-pairs { .mapper-pairs {

Datei anzeigen

@ -85,8 +85,11 @@ class CustomWizard::Mapper
key = map_field(pair['key'], pair['key_type']) key = map_field(pair['key'], pair['key_type'])
connector = pair['connector'] connector = pair['connector']
operator = map_operator(connector) operator = map_operator(connector)
value = interpolate(map_field(pair['value'], pair['value_type'])) value = cast_value(
value = Regexp.new(value) if connector == 'regex' key,
interpolate(map_field(pair['value'], pair['value_type'])),
connector
)
begin begin
failed = !cast_result(key.public_send(operator, value), connector) failed = !cast_result(key.public_send(operator, value), connector)
@ -98,6 +101,20 @@ class CustomWizard::Mapper
!failed !failed
end end
def cast_value(key, value, connector)
if connector == 'regex'
Regexp.new(value)
else
if key.is_a?(String)
value.to_s
elsif key.is_a?(Integer)
value.to_i
else
value
end
end
end
def cast_result(result, connector) def cast_result(result, connector)
if connector == 'regex' if connector == 'regex'
result == 0 ? true : false result == 0 ? true : false