Module Wac::XmlContainer

  1. lib/wac/xml_container.rb

mixin this module to get sensible default methods for xml container classes

Methods

public instance

  1. respond_to?

protected instance

  1. method_missing
  2. xml_value

Attributes

xml [R]

Public instance methods

respond_to? (method, include_private = false)
[show source]
# File lib/wac/xml_container.rb, line 6
    def respond_to?(method, include_private = false)
      xml.key?(method.to_s) || super
    end

Protected instance methods

method_missing (method, *args)
[show source]
# File lib/wac/xml_container.rb, line 22
    def method_missing(method, *args)
      if xml.key?(method.to_s)
        xml_value(xml[method.to_s])
      else
        super
      end
    end
xml_value (val)
[show source]
# File lib/wac/xml_container.rb, line 11
    def xml_value(val)
      case val
      when "true" then true
      when "false" then false
      when "" then nil
      when /^\d+$/ then val.to_i
      when /^\d+\.\d+$/ then val.to_f
      else val
      end
    end