From 6de241be8134a2b25ef17a5418db0348df07423c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 23 Nov 2008 14:07:43 -0800 Subject: Lazy-require builder lib --- activesupport/lib/active_support/core_ext/array/conversions.rb | 3 +-- activesupport/lib/active_support/core_ext/hash/conversions.rb | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index cf3e03f62c..f0d6591135 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -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 diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 50dc7c61fc..a76c8a2259 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -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" }) -- cgit v1.2.3