Class: Enumerize::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/enumerize/xml.rb

Instance Method Summary collapse

Instance Method Details

#localizeObject Also known as: l


3
4
5
# File 'lib/enumerize/xml.rb', line 3

def localize
  text
end

#to_xml(options = {}) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/enumerize/xml.rb', line 8

def to_xml(options = {})
  require 'active_support/builder' unless defined?(Builder)

  options = options.dup
  options[:indent] ||= 2
  options[:root] ||= 'hash'
  options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])

  builder = options[:builder]
  builder.instruct! unless options.delete(:skip_instruct)

  root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)

  builder.__send__(:method_missing, root, localize, name: to_s)
end