Sha256: 7d37afecc5647559d8684467e9a331505d560cb7ef205f5db59aa0ccd0e0254e
Contents?: true
Size: 981 Bytes
Versions: 8
Compression:
Stored size: 981 Bytes
Contents
module Soybean module ComplexType extend ActiveSupport::Concern included do include Soybean::SoapAttribute end module InstanceMethods def initialize(*args) hash = args.extract_options! if args.empty? init_from_hash(hash) else init_from_array(args) end end private # @param hash [Hash] def init_from_hash(hash) check_arguments_number!(hash) hash.each do |key, val| self.send key.to_sym, val end end # @param arry [Array] def init_from_array(arry) check_arguments_number! arry attributes.each_with_index do |key, i| self.send "#{key}=".to_sym, arry.at(i) end end def check_arguments_number!(args) if args.size != attributes.size raise ArgumentError, "wrong number of arguments(#{args.size} for #{attributes.size})" end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems