lib/rbbt/util/misc/objects.rb in rbbt-util-5.15.1 vs lib/rbbt/util/misc/objects.rb in rbbt-util-5.15.2

- old
+ new

@@ -5,14 +5,14 @@ return entity unless String === entity or Array === entity options ||= {} dup_array = options.delete :dup_array - if Entity === field or (Entity.respond_to?(:formats) and Entity.formats.include? field) + if Entity === field or (Entity.respond_to?(:formats) and (_format = Entity.formats.find(field))) params = options.dup params[:format] ||= params.delete "format" - params.merge!(:format => field) unless params.include?(:format) and not ((f = params[:format]).nil? or (String === f and f.empty?)) + params.merge!(:format => _format) unless _format.nil? or (params.include?(:format) and not ((f = params[:format]).nil? or (String === f and f.empty?))) mod = Entity === field ? field : Entity.formats[field] entity = mod.setup( ((entity.frozen? and not entity.nil?) ? entity.dup : ((Array === entity and dup_array) ? entity.collect{|e| e.nil? ? e : e.dup} : entity) ), params