lib/frenchy/model.rb in frenchy-0.0.3 vs lib/frenchy/model.rb in frenchy-0.0.4

- old
+ new

@@ -115,12 +115,15 @@ else options[:class_name] ||= type.to_s.camelize options[:many] = (name.to_s.singularize != name.to_s) unless options.key?(:many) klass = options[:class_name].constantize + if options[:many] + options[:default] ||= [] + end + define_method("#{name}=") do |v| if options[:many] - options[:default] ||= [] set(name, Frenchy::Collection.new(Array(v).map {|vv| klass.new(vv)})) else set(name, klass.new(v)) end end