Class: OpenXmlObject

Inherits:
SOAP::Mapping::Object
  • Object
show all
Defined in:
lib/mappum/open_xml_object.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mappum/open_xml_object.rb', line 23

def method_missing(sym, *args, &block)
  
  safename = XSD::CodeGen::GenSupport.safemethodname(sym.to_s).to_sym
  
  if safename != sym and self.respond_to?(safename)
    return self.send(safename, *args, &block)
  end
  
  if sym.to_s[-1..-1] == "=" then
    if sym.to_s[0..7] == "xmlattr_"
      #attribute
      name = sym.to_s[8..-2]
      __add_xmlattr_from_method(name, args[0])
    else
      #element
      __add_xmlele_from_method(sym.to_s[0..-2], args[0])
    end        
  else  
    super(sym, *args, &block)
  end
end

Instance Method Details

#id=(value) ⇒ Object



44
45
46
# File 'lib/mappum/open_xml_object.rb', line 44

def id=(value)
  __add_xmlele_from_method("id", value)        
end

#type=(value) ⇒ Object



47
48
49
# File 'lib/mappum/open_xml_object.rb', line 47

def type=(value)
  __add_xmlele_from_method("type",value)        
end