Skip to content

Commit

Permalink
Use sym as additional argument to template! in order to pass @namespace
Browse files Browse the repository at this point in the history
…. LC-111
  • Loading branch information
Abby Ihrig committed Jun 10, 2014
1 parent 282b5bf commit 6fe119c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/eloqua/builder/xml.rb
Expand Up @@ -56,9 +56,9 @@ class Xml < ::Builder::XmlMarkup
end

# defines entity attribute fields for use in update/create
define_builder_template :fields do |xml, object_type, entity_attributes|
define_builder_template :fields do |xml, object_type, entity_attributes, sym|
entity_attributes.each do |attribute, value|
xml.tag!("#{object_type.to_s.camelize}Fields") do
xml.tag!("#{sym.to_s}:#{object_type.to_s.camelize}Fields") do
xml.InternalName(attribute.to_s)
xml.Value(value)
end
Expand All @@ -67,8 +67,9 @@ class Xml < ::Builder::XmlMarkup

# Dynamic entity for update/create/etc...

define_builder_template :dynamic do |xml, object_type, type, id, attributes|
xml.tag!("#{object_type.to_s.camelize}Type") do
define_builder_template :dynamic do |xml, object_type, type, id, attributes, sym|

xml.tag!("#{sym.to_s}:#{object_type.to_s.camelize}Type") do
xml.template!(:object_type, type)
end

Expand All @@ -95,11 +96,14 @@ def self.create(options = {}, &block)
end

def template!(template, *args)
sym = @namespace
args << sym
builder_template(template, *args).call(self)
end

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

def object_type!(sym, *args, &block)
Expand All @@ -110,8 +114,9 @@ def object_type_lower!(sym, *args, &block)
tag!("#{sym}Type", *args, &block)
end

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

# Extend to allow default namespace
Expand All @@ -120,7 +125,8 @@ def method_missing(sym, *args, &block)
args.unshift(sym.to_sym)
sym = @namespace
end
super(sym, *args, &block)
super(sym, *args, &block) unless sym.to_s == "block_given?"

end

end
Expand Down

0 comments on commit 6fe119c

Please sign in to comment.