For an array :funThings, we collect all <funThing/> elements (XmlSimple actually does the collecting)
# File lib/cimi/models/schema.rb, line 232 def initialize(name, opts = {}, &block) unless opts[:xml_name] opts[:xml_name] = name.to_s.singularize.camelize.uncapitalize end if opts[:ref] && block_given? raise "Provide only one of :ref or a block" end super(name, opts) if opts[:ref] @struct = Ref.new(name, :class=> opts[:ref]) else @struct = Struct.new(name, opts, &block) end end
# File lib/cimi/models/schema.rb, line 251 def from_json(json, model) model[name] = (json[json_name] || []).map { |elt| @struct.convert_from_json(elt) } end
# File lib/cimi/models/schema.rb, line 247 def from_xml(xml, model) model[name] = (xml[xml_name] || []).map { |elt| @struct.convert_from_xml(elt) } end
# File lib/cimi/models/schema.rb, line 260 def to_json(model, json) ary = (model[name] || []).map { |elt| @struct.convert_to_json(elt) } json[json_name] = ary unless ary.empty? end
# File lib/cimi/models/schema.rb, line 255 def to_xml(model, xml) ary = (model[name] || []).map { |elt| @struct.convert_to_xml(elt) } xml[xml_name] = ary unless ary.empty? end