lib/cieloz/requisicao.rb in cieloz-0.0.19 vs lib/cieloz/requisicao.rb in cieloz-0.0.20
- old
+ new
@@ -17,29 +17,31 @@
name = self.class.name.demodulize
@xml = x.tag! name.underscore.dasherize, id: id, versao: versao do
attributes.each { |attr, value|
next if value.nil?
- unless value.respond_to? :attributes
- x.tag! dash(attr), value
- else
- x.tag! dash(attr) do
+ if value.respond_to? :build_xml
+ value.build_xml x
+ elsif value.respond_to? :attributes
+ x.tag! dasherize_attr(attr) do
value.attributes.each do |attr, value|
- x.tag!(dash(attr), value) unless value.blank?
+ x.tag!(dasherize_attr(attr), value) unless value.blank?
end
end
+ else
+ x.tag! dasherize_attr(attr), value
end
}
end
end
def submit
@dados_ec = Cieloz::Configuracao.credenciais
if valid?
@id = SecureRandom.uuid if id.blank?
- @versao = "1.2.0" if versao.blank?
+ @versao = "1.2.1" if versao.blank?
http = Net::HTTP.new Cieloz::Configuracao.host, 443
http.use_ssl = true
http.open_timeout = 5 * 1000
http.read_timeout = 30 * 1000
@@ -66,12 +68,7 @@
doc = Nokogiri::XML @xml
portador = '//requisicao-transacao//dados-portador'
doc.xpath(portador).children.each {|node| node.content = "*" }
doc.to_xml
end
- end
-
- private
- def dash value
- value.to_s.gsub("@", "").dasherize
end
end