Parent

Included Modules

Class/Module Index [+]

Quicksearch

CIMI::Model::Schema

The smarts of converting from XML and JSON into internal objects

Public Class Methods

new() click to toggle source

The actual Schema class

# File lib/cimi/model/schema.rb, line 206
def initialize
  @attributes = []
end

Public Instance Methods

add_attributes!(args, attr_klass, &block) click to toggle source
# File lib/cimi/model/schema.rb, line 272
def add_attributes!(args, attr_klass, &block)
  raise "The schema has already been used to convert objects" if @attributes.frozen?
  opts = args.extract_opts!
  args.each { |arg| @attributes << attr_klass.new(arg, opts, &block) }
end
attribute_names() click to toggle source
# File lib/cimi/model/schema.rb, line 234
def attribute_names
  @attributes.map { |a| a.name }
end
from_json(json, model = {}) click to toggle source
# File lib/cimi/model/schema.rb, line 216
def from_json(json, model = {})
  @attributes.freeze
  @attributes.each { |attr| attr.from_json(json, model) }
  model
end
from_xml(xml, model = {}) click to toggle source
# File lib/cimi/model/schema.rb, line 210
def from_xml(xml, model = {})
  @attributes.freeze
  @attributes.each { |attr| attr.from_xml(xml, model) }
  model
end
to_json(model, json = {}) click to toggle source
# File lib/cimi/model/schema.rb, line 228
def to_json(model, json = {})
  @attributes.freeze
  @attributes.each { |attr| attr.to_json(model, json) }
  json
end
to_xml(model, xml = {}) click to toggle source
# File lib/cimi/model/schema.rb, line 222
def to_xml(model, xml = {})
  @attributes.freeze
  @attributes.each { |attr| attr.to_xml(model, xml) }
  xml
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.