Class: Eloqua::Builder::Xml

Inherits:
Builder::XmlMarkup
  • Object
show all
Includes:
Templates
Defined in:
lib/eloqua/builder/xml.rb

Overview

This could (and likely should) be submitted as a patch for the main builder class

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Xml

Returns a new instance of Xml.

Yields:

  • (_self)

Yield Parameters:



97
98
99
100
101
102
# File 'lib/eloqua/builder/xml.rb', line 97

def initialize(options = {}, &block)
  super
  @namespace = nil
  @namespace = options[:namespace].to_sym if options[:namespace]
  yield self if ::Kernel.block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Extend to allow default namespace



129
130
131
132
133
134
135
# File 'lib/eloqua/builder/xml.rb', line 129

def method_missing(sym, *args, &block)
  if(@namespace && !args.first.kind_of?(::Symbol))
    args.unshift(sym.to_sym)
    sym = @namespace
  end
  super(sym, *args, &block)
end

Class Method Details

.create(options = {}, &block) ⇒ Object



104
105
106
# File 'lib/eloqua/builder/xml.rb', line 104

def self.create(options = {}, &block)
  new(options, &block).target!
end

Instance Method Details

#dynamic_object!(sym, *args, &block) ⇒ Object



112
113
114
# File 'lib/eloqua/builder/xml.rb', line 112

def dynamic_object!(sym, *args, &block)
  tag!("Dynamic#{sym.to_s.camelize}", *args, &block)
end

#object_collection!(sym, *args, &block) ⇒ Object



124
125
126
# File 'lib/eloqua/builder/xml.rb', line 124

def object_collection!(sym, *args, &block)
  tag!("#{sym.to_s.pluralize.downcase}", *args, &block)
end

#object_type!(sym, *args, &block) ⇒ Object



116
117
118
# File 'lib/eloqua/builder/xml.rb', line 116

def object_type!(sym, *args, &block)
  tag!("#{sym.to_s.camelize}Type", *args, &block)
end

#object_type_lower!(sym, *args, &block) ⇒ Object



120
121
122
# File 'lib/eloqua/builder/xml.rb', line 120

def object_type_lower!(sym, *args, &block)
  tag!("#{sym}Type", *args, &block)
end

#template!(template, *args) ⇒ Object



108
109
110
# File 'lib/eloqua/builder/xml.rb', line 108

def template!(template, *args)
  ::Eloqua::Builder::Xml.builder_template(template, *args).call(self)
end