lib/wash_out/param.rb in wash_out-0.3.0 vs lib/wash_out/param.rb in wash_out-0.3.1

- old
+ new

@@ -29,23 +29,29 @@ check_if_missing(data) data = Array(data) if @multiplied if struct? - map_struct(data) { |param, elem| param.load(elem) } + if @multiplied + data.map do |x| + map_struct(x) { |param, elem| param.load(elem) } + end + else + map_struct(data) { |param, elem| param.load(elem) } + end else operation = case type when 'string'; :to_s when 'integer'; :to_i when 'double'; :to_f when 'boolean'; nil # Nori handles that for us else raise RuntimeError, "Invalid WashOut simple type: #{type}" end - + if operation.nil? data - elsif data.is_a? Array + elsif @multiplied data.map{|x| x.send(operation)} else data.send(operation) end end @@ -78,11 +84,11 @@ # # This function returns an array of WashOut::Param objects. def self.parse_def(definition) raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == [] return [] if definition == nil - + if [Array, Symbol].include?(definition.class) definition = { :value => definition } end if definition.is_a? Hash @@ -97,11 +103,11 @@ end else raise RuntimeError, "Wrong definition: #{type.inspect}" end end - + def clone copy = self.class.new(@name, @type.to_sym, @multiplied) copy.map = @map.map{|x| x.clone} copy end @@ -122,10 +128,10 @@ end # Raise an appropriate exception if a required datum is missing. def check_if_missing(data) if data.nil? - raise WashOut::Dispatcher::SOAPError, "Required SOAP parameter #{@name} is missing" + raise WashOut::Dispatcher::SOAPError, "Required SOAP parameter '#{@name}' is missing" end end end end