# File lib/cimi/models/schema.rb, line 56 def initialize(name, opts) @text = opts[:text] if ! [nil, :nested, :direct].include?(@text) raise "text option for scalar must be :nested or :direct" end super(name, opts) end
# File lib/cimi/models/schema.rb, line 68 def from_xml(xml, model) case @text when :nested then model[@name] = xml[@xml_name].first["content"] if xml[@xml_name] when :direct then model[@name] = xml["content"] else model[@name] = xml[@xml_name] end end
# File lib/cimi/models/schema.rb, line 66 def nested_text?; @text == :nested; end
# File lib/cimi/models/schema.rb, line 64 def text?; @text; end
# File lib/cimi/models/schema.rb, line 76 def to_xml(model, xml) return unless model return unless model[@name] case @text when :nested then xml[@xml_name] = [{ "content" => model[@name] }] when :direct then xml["content"] = model[@name] else xml[@xml_name] = model[@name] end end