module XMLable::Mixins::BareValue
BareValue
contains logic to get the bare value.
All XML object such as Integer, Date, String, etc are wrapped with the proxy classes. This module helps to unwrap the real value.
Public Instance Methods
[](key)
click to toggle source
Get object value
It unwraps the object value if object key ends with '!' symbol.
@return [XMLable::Mixins::Object, Object
, nil]
Calls superclass method
# File lib/xmlable/mixins/bare_value.rb, line 22 def [](key) return super unless key.to_s =~ /!$/ __extract_bare_value(super) end
__extract_bare_value(obj)
click to toggle source
Unwrap objects
@param [XMLable::Mixins::Object, Array<XMLable::Mixins::Object>] obj
@api private
@return [Object, Array<Object>]
# File lib/xmlable/mixins/bare_value.rb, line 36 def __extract_bare_value(obj) obj.respond_to?(:map) ? obj.map(&:__object) : obj.__object end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/xmlable/mixins/bare_value.rb, line 9 def method_missing(name, *args, &block) return super unless name.to_s =~ /!$/ return super unless key?(name) name = name.to_s.gsub(/!$/,'').to_sym __extract_bare_value(super) end