lib/gloo/core/obj.rb in gloo-0.6.1 vs lib/gloo/core/obj.rb in gloo-0.7.0

- old
+ new

@@ -10,18 +10,22 @@ class Obj < Baseo attr_accessor :value attr_reader :children, :parent + # # Set up the object. + # def initialize @value = '' @children = [] @parent = nil end + # # Register object types when they are loaded. + # def self.inherited( subclass ) Dictionary.instance.register_obj( subclass ) end # @@ -43,11 +47,13 @@ # def set_parent( obj ) @parent = obj end + # # Is this the root object? + # def root? return false if @parent return false unless name.downcase == 'root' return true @@ -147,29 +153,37 @@ :value => nil, :parent => self } return $engine.factory.create params end + # # Add a child object to the container. + # def add_child( obj ) @children << obj obj.set_parent self end + # # Get the number of children. + # def child_count return @children.count end + # # Does this object contain an object with the given name? + # def contains_child?( name ) @children.each do |o| return true if name.downcase == o.name.downcase end return false end + # # Find a child object with the given name. + # def find_child( name ) if name.end_with?( Gloo::Objs::Alias::ALIAS_REFERENCE ) name = name[ 0..-2 ] end