module Soybean::ComplexType::InstanceMethods
Public Class Methods
new(*args)
click to toggle source
# File lib/soybean/complex_type.rb, line 10 def initialize(*args) hash = args.extract_options! if args.empty? init_from_hash(hash) else init_from_array(args) end end
Private Instance Methods
check_arguments_number!(args)
click to toggle source
# File lib/soybean/complex_type.rb, line 37 def check_arguments_number!(args) if args.size != attributes.size raise ArgumentError, "wrong number of arguments(#{args.size} for #{attributes.size})" end end
init_from_array(arry)
click to toggle source
@param arry [Array]
# File lib/soybean/complex_type.rb, line 30 def init_from_array(arry) check_arguments_number! arry attributes.each_with_index do |key, i| self.send :"#{key}=", arry.at(i) end end
init_from_hash(hash)
click to toggle source
@param hash [Hash]
# File lib/soybean/complex_type.rb, line 22 def init_from_hash(hash) check_arguments_number!(hash) hash.each do |key, val| self.send key.to_sym, val end end