Class Index [+]

Quicksearch

ActiveSupport::XmlMini

XmlMini

To use the much faster libxml parser:

  gem 'libxml-ruby', '=0.9.7'
  XmlMini.backend = 'LibXML'

Constants

DEFAULT_ENCODINGS
TYPE_NAMES
FORMATTING
PARSING

Attributes

backend[R]

Public Instance Methods

backend=(name) click to toggle source
    # File lib/active_support/xml_mini.rb, line 80
80:     def backend=(name)
81:       if name.is_a?(Module)
82:         @backend = name
83:       else
84:         require "active_support/xml_mini/#{name.to_s.downcase}"
85:         @backend = ActiveSupport.const_get("XmlMini_#{name}")
86:       end
87:     end
rename_key(key, options = {}) click to toggle source
     # File lib/active_support/xml_mini.rb, line 128
128:     def rename_key(key, options = {})
129:       camelize  = options.has_key?(:camelize) && options[:camelize]
130:       dasherize = !options.has_key?(:dasherize) || options[:dasherize]
131:       key = key.camelize  if camelize
132:       key = _dasherize(key) if dasherize
133:       key
134:     end
to_tag(key, value, options) click to toggle source
     # File lib/active_support/xml_mini.rb, line 96
 96:     def to_tag(key, value, options)
 97:       type_name = options.delete(:type)
 98:       merged_options = options.merge(:root => key, :skip_instruct => true)
 99: 
100:       if value.is_a?(::Method) || value.is_a?(::Proc)
101:         if value.arity == 1
102:           value.call(merged_options)
103:         else
104:           value.call(merged_options, key.to_s.singularize)
105:         end
106:       elsif value.respond_to?(:to_xml)
107:         value.to_xml(merged_options)
108:       else
109:         type_name ||= TYPE_NAMES[value.class.name]
110:         type_name ||= value.class.name if value && !value.respond_to?(:to_str)
111:         type_name   = type_name.to_s   if type_name
112: 
113:         key = rename_key(key.to_s, options)
114: 
115:         attributes = options[:skip_types] || type_name.nil? ? { } : { :type => type_name }
116:         attributes[:nil] = true if value.nil?
117: 
118:         encoding = options[:encoding] || DEFAULT_ENCODINGS[type_name]
119:         attributes[:encoding] = encoding if encoding
120: 
121:         formatted_value = FORMATTING[type_name] && !value.nil? ?
122:           FORMATTING[type_name].call(value) : value
123: 
124:         options[:builder].tag!(key, formatted_value, attributes)
125:       end
126:     end
with_backend(name) click to toggle source
    # File lib/active_support/xml_mini.rb, line 89
89:     def with_backend(name)
90:       old_backend, self.backend = backend, name
91:       yield
92:     ensure
93:       self.backend = old_backend
94:     end

Protected Instance Methods

_dasherize(key) click to toggle source
     # File lib/active_support/xml_mini.rb, line 138
138:     def _dasherize(key)
139:       key.gsub(/(?!^[_]*)_(?![_]*$)/, '-')
140:     end
_parse_file(file, entity) click to toggle source
     # File lib/active_support/xml_mini.rb, line 152
152:     def _parse_file(file, entity)
153:       f = StringIO.new(ActiveSupport::Base64.decode64(file))
154:       f.extend(FileLike)
155:       f.original_filename = entity['name']
156:       f.content_type = entity['content_type']
157:       f
158:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.