Class Core::Model::Support::Property
In: core/model/support.rb
Parent: Object

Each property defined for a node inside the universe.xml will be loaded into an instance of this class. There are two types of properties: simple (Property) and multiple choice (MultipleChoiceProperty).

Property objects store the name, type and value of a property. They can be serialized to_xml.

Methods

Attributes

key  [RW] 
name  [RW] 
populator  [RW] 
type  [RW] 
value  [RW] 

Public Class methods

[Source]

# File core/model/support.rb, line 35
        def initialize(key, name, value, populator=nil)
          @key = key
          @name = name
          @value = value
          @populator = populator
        end

Public Instance methods

[Source]

# File core/model/support.rb, line 56
        def populator
          # If the populator has not been instantiated, do so now. There is no
          # problem if the populator is nil, instance_of? evaluates to +false+
          if @populator.instance_of?(String)
            begin
              @populator = eval(@populator).new
            rescue
              $logger.error{ "There was an error instantiating #{@populator}: #{$!}" }
              $logger.debug{ $@ }
              @populator = nil
            end
          end
          
          return @populator
        end

[Source]

# File core/model/support.rb, line 53
        def populator_defined?
          return !@populator.nil?
        end

[Source]

# File core/model/support.rb, line 42
        def to_xml(options = {})
          xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
          xml.instruct! unless options[:skip_instruct]
          xml.property { 
            xml.key @key.to_s
            xml.name @name 
            xml.type @value.class.to_s
            xml.value @value
          }
        end

[Validate]