mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Lazy-require builder lib
This commit is contained in:
parent
31ce92f7b5
commit
6de241be81
2 changed files with 3 additions and 3 deletions
|
@ -1,5 +1,3 @@
|
|||
require 'builder'
|
||||
|
||||
module ActiveSupport #:nodoc:
|
||||
module CoreExtensions #:nodoc:
|
||||
module Array #:nodoc:
|
||||
|
@ -149,6 +147,7 @@ module ActiveSupport #:nodoc:
|
|||
#
|
||||
def to_xml(options = {})
|
||||
raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
|
||||
require 'builder' unless defined?(Builder)
|
||||
|
||||
options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records"
|
||||
options[:children] ||= options[:root].singularize
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require 'date'
|
||||
require 'cgi'
|
||||
require 'builder'
|
||||
require 'xmlsimple'
|
||||
|
||||
# Locked down XmlSimple#xml_in_string
|
||||
|
@ -113,6 +112,8 @@ module ActiveSupport #:nodoc:
|
|||
alias_method :to_param, :to_query
|
||||
|
||||
def to_xml(options = {})
|
||||
require 'builder' unless defined?(Builder)
|
||||
|
||||
options[:indent] ||= 2
|
||||
options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
|
||||
:root => "hash" })
|
||||
|
|
Loading…
Reference in a new issue