lib/babel/serializer.rb in vellam-0.1.1 vs lib/babel/serializer.rb in vellam-0.1.2

- old
+ new

@@ -51,13 +51,12 @@ filter.use(context_or_options) self end def to_hash(options = nil) - filter.use(options) if options - case @model_or_models - when Array + filter.use(filter.options.dup.merge!(options)) if options + if @model_or_models.respond_to?(:collect) && ! @model_or_models.is_a?(Hash) @model_or_models.collect do |m| filter_model(attr(m), m) end else filter_model(attr(@model_or_models), @model_or_models) @@ -66,11 +65,11 @@ def to_json(options = nil) to_hash(options).to_json end - def to_xml(options = nil) - opts = fitler.options.dup + def to_xml(options = {}) + opts = filter.options.dup.merge!(options) root = opts.delete :root fitler.use(opts) result = to_hash if root && result.is_a?(Array) && root.respond_to?(:pluralize) root = root.to_s.pluralize