This class represents a single node in a schema "tree". The entire tree is the actual schema, where it is recursively defined using instances of this class.

Methods
Attributes
[R] definition The children nodes of this schema node. If nil, then this is a leaf node.
[R] description The optional description of this schema.
[RW] extends The schema that this schema extends.
[R] name The optional name of this schema.
[RW] owner The owning package of this schema.
[R] processor_path The path description that identifies the class to use when processing this schema.
[R] required Whether or not this node is required.
[R] type The type of this node. If nil, then it may be of any type.
Classes and Modules
Module Copland::Schema::Fixated
Public Class methods
new( name, processor, description, required, type, definition, extends )

Create a new schema node with the given name, processor class, description, required-flag, type, and definition. If processor is nil, then the DefaultSchemaProcessor class will be used.

    # File lib/copland/schema.rb, line 72
72:     def initialize( name, processor, description,
73:                     required, type, definition,
74:                     extends )
75:     #begin
76:       @definition, @description, @name = definition, description, name
77:       @processor_path, @required, @type = processor, required, type
78:       @extends = extends
79:     end
Public Instance methods
fixate!()

Fixate the schema by recursively processing each subschema. If any subschema is actually a string, it is replaced by the schema with that name.

     # File lib/copland/schema.rb, line 164
164:     def fixate!
165:       extend Fixated
166: 
167:       if @extends
168:         new_definition = @owner.find_schema( @extends ).definition.dup
169:         new_definition.update @definition if @definition
170:         @definition = new_definition
171:       end
172: 
173:       if @definition.is_a?( String )
174:         @definition = @owner.find_schema( @definition ).definition
175:       elsif @definition.is_a?( Hash )
176:         @definition.each_key do |key|
177:           value = @definition[ key ]
178:           if value.is_a?( String )
179:             @definition[ key ] = @owner.find_schema( value )
180:           else
181:             value.fixate!
182:           end
183:         end
184:       end
185:     end
fixated?()

Returns false.

     # File lib/copland/schema.rb, line 188
188:     def fixated?
189:       false
190:     end
full_name()

Returns the fully-qualified name of this schema, but only if the schema has both a name and an owning package. Otherwise, it returns nil.

    # File lib/copland/schema.rb, line 83
83:     def full_name
84:       if @owner && @name
85:         @owner.name + "." + @name
86:       end
87:     end
process( owner, client, data, path="/", processor=nil )

Preprocess the given data against this schema node. The owner is the service point (or configuration point) that the schema is being processed for, and the client is the service point (or configuration point) that the data is being processed for. If path is given, it represents the path through the schema leading to this node. If processor is given, then it should be used to process this node as long as it is of the same type as this node’s processor.

The preprocessed data is returned.

     # File lib/copland/schema.rb, line 128
128:     def process( owner, client, data, path="/", processor=nil )
129:       processor = get_processor( processor )
130: 
131:       if processor.respond_to?( :process )
132:         return processor.process( owner, client, self, data, path )
133:       end
134: 
135:       return data
136:     end
validate( owner, client, data, path="/", processor=nil )

Validate the given data against this schema node. The owner is the service point (or configuration point) that the schema is being processed for, and the client is the service point (or configuration point) that the data is being processed for. If path is given, it represents the path through the schema leading to this node. If processor is given, then it should be used to process this node as long as it is of the same type as this node’s processor.

     # File lib/copland/schema.rb, line 96
 96:     def validate( owner, client, data, path="/", processor=nil )
 97:       # always make sure the schema has been fixated before we try to validate
 98:       # anything with it.
 99:       fixate!
100: 
101:       processor = get_processor( processor )
102: 
103:       if processor.respond_to?( :validate )
104:         if data.is_a?( Array ) ||
105:           ( data.respond_to?( :type_id ) && data.type_id == "array" )
106:         # then
107:           data = data.value if data.respond_to?( :type_id )
108:           index = 0
109:           data.each do |item|
110:             processor.validate( owner, client, self, item, "#{path}[#{index}]" )
111:             index += 1
112:           end
113:         else
114:           processor.validate( owner, client, self, data, path )
115:         end
116:       end
117:     end