module XML::XXPath::Accessors::UnspecifiednessSupport
we need a boolean “unspecified?” attribute for XML nodes – paths like “*” oder (somewhen) “foo|bar” create “unspecified” nodes that the user must then “specify” by setting their text etc. (or manually setting unspecified=false)
This is mixed into the REXML::Element and XML::XXPath::Accessors::Attribute classes.
Public Class Methods
append_features(base)
click to toggle source
Calls superclass method
# File lib/xml/rexml_ext.rb, line 28 def self.append_features(base) return if base.included_modules.include? self # avoid aliasing methods more than once # (would lead to infinite recursion) super base.module_eval <<-EOS alias_method :_text_orig, :text alias_method :_textis_orig, :text= def text # we're suffering from the "fragile base class" # phenomenon here -- we don't know whether the # implementation of the class we get mixed into always # calls text (instead of just accessing @text or so) if unspecified? "[UNSPECIFIED]" else _text_orig end end def text=(x) _textis_orig(x) self.unspecified=false end alias_method :_nameis_orig, :name= def name=(x) _nameis_orig(x) self.unspecified=false end EOS end
Public Instance Methods
unspecified=(x)
click to toggle source
# File lib/xml/rexml_ext.rb, line 24 def unspecified=(x) @xml_xpath_unspecified = x end
unspecified?()
click to toggle source
# File lib/xml/rexml_ext.rb, line 20 def unspecified? @xml_xpath_unspecified ||= false end