lib/gloo/core/obj.rb in gloo-3.4.1 vs lib/gloo/core/obj.rb in gloo-3.5.0

- old
+ new

@@ -214,10 +214,34 @@ return redirect.find_child( name ) end return nil end + # + # Find a child, resolve any alias references. + # This returns the object, not the value. + # + def find_child_resolve_alias( name ) + o = find_child name + return nil unless o + + o = Gloo::Objs::Alias.resolve_alias( @engine, o ) + return o + end + + # + # Find a child, resolve any alias references, + # and return the object's value. + # + def find_child_value( name ) + o = find_child name + return nil unless o + + o = Gloo::Objs::Alias.resolve_alias( @engine, o ) + return o&.value + end + # # Get the index of the child with the given name. # def child_index( name ) @children.each_with_index do |o, i| @@ -262,11 +286,11 @@ # # Get a list of message names that this object receives. # def self.messages - return %w[reload unload] + return %w[reload unload blank? contains?] end # # Can this object receive a message? # @@ -280,11 +304,11 @@ # def send_message( msg, params = nil ) @params = params return self.dispatch msg if self.can_receive_message? msg - @engine.log.error "Object #{self.name} cannot receive message #{msg}" + @engine.err "Object #{self.name} cannot receive message #{msg}" return false end # # Dispatch the message to the object. @@ -293,21 +317,21 @@ o = "msg_#{msg}" if self.respond_to? o self.public_send( o ) return true else - @engine.log.error "Message #{msg} not implemented" + @engine.err "Message #{msg} not implemented" return false end end # # Send the object the unload message. # def msg_unload if self.root? - @engine.log.error 'Cannot unload the root object.' + @engine.err 'Cannot unload the root object.' return end @engine.persist_man.unload self end @@ -316,14 +340,32 @@ # Send the object the reload message. # Note that this will only work for objects with file assoications. # def msg_reload if self.root? - @engine.log.error 'Cannot reload the root object.' + @engine.err 'Cannot reload the root object.' return end @engine.persist_man.reload self + end + + # + # Check to see if the value is blank. + # + def msg_blank? + val_blank = value.blank? + @engine.heap.it.set_to val_blank + return val_blank + end + + # + # Check to see if there are children. + # + def msg_contains? + has_children = child_count.positive? + @engine.heap.it.set_to has_children + return has_children end # --------------------------------------------------------------------- # Render