Sha256: def9df00a775564f6f6154e4d1623487d12e3e5750580f6aad41307344a7b043
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require "xmlmapper" module Xmlenc module Builder module Base extend ActiveSupport::Concern included do include ::XmlMapper include ::ActiveModel::Validations extend XmlMapperClassMethods include XmlMapperInstanceMethods end module XmlMapperInstanceMethods def initialize(attributes = {}) attributes.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") && value.present? end end def from_xml=(bool) @from_xml = bool end def from_xml? @from_xml end end module XmlMapperClassMethods def parse(xml, options = {}) raise Xmlenc::UnparseableMessage.new("Unable to parse nil document") if xml.nil? object = super if object.is_a?(Array) object.map { |x| x.from_xml = true } elsif object object.from_xml = true end object rescue Nokogiri::XML::SyntaxError => e raise Xmlenc::UnparseableMessage.new(e.message) rescue NoMethodError => e raise Xmlenc::UnparseableMessage.new(e.message) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xmlenc-0.8.0 | lib/xmlenc/builder/base.rb |