lib/wash_out/param.rb in wash_out-0.6.1 vs lib/wash_out/param.rb in wash_out-0.7.0

- old
+ new

@@ -45,10 +45,11 @@ data = data[key] data = [data] if @multiplied && !data.is_a?(Array) if struct? + data ||= {} if @multiplied data.map do |x| map_struct x do |param, data, elem| param.load(data, elem) end @@ -61,21 +62,22 @@ else operation = case type when 'string'; :to_s when 'integer'; :to_i when 'double'; :to_f - when 'boolean'; nil + when 'boolean'; lambda{|data| data === "0" ? false : !!data} when 'date'; :to_date when 'datetime'; :to_datetime when 'time'; :to_time else raise RuntimeError, "Invalid WashOut simple type: #{type}" end begin - if operation.nil? || data.nil? + if data.nil? data elsif @multiplied - data.map{|x| x.send(operation)} + return data.map{|x| x.send(operation)} if operation.is_a?(Symbol) + return data.map{|x| operation.call(x)} if operation.is_a?(Proc) elsif operation.is_a? Symbol data.send(operation) else operation.call(data) end