# File lib/cimi/model/schema.rb, line 82 def initialize(name, opts, &block) content = opts[:content] super(name, opts) @schema = CIMI::Model::Schema.new @schema.instance_eval(&block) if block_given? @schema.scalar(content, :text => :direct) if content end
# File lib/cimi/model/schema.rb, line 116 def convert_from_json(json) sub = struct.new @schema.from_json(json, sub) sub end
# File lib/cimi/model/schema.rb, line 110 def convert_from_xml(xml) sub = struct.new @schema.from_xml(xml, sub) sub end
# File lib/cimi/model/schema.rb, line 128 def convert_to_json(model) json = {} @schema.to_json(model, json) json end
# File lib/cimi/model/schema.rb, line 122 def convert_to_xml(model) xml = {} @schema.to_xml(model, xml) xml end
# File lib/cimi/model/schema.rb, line 95 def from_json(json, model) json = json.has_key?(json_name) ? json[json_name] : {} model[name] = convert_from_json(json) end
# File lib/cimi/model/schema.rb, line 90 def from_xml(xml, model) xml = xml.has_key?(xml_name) ? xml[xml_name].first : {} model[name] = convert_from_xml(xml) end
Generated with the Darkfish Rdoc Generator 2.