module Context class Widget attr_reader :delegate def initialize(delegate) @delegate = delegate end # This method is called after the widget has been # successfully added to another widget def addedTo(widget) # This is an abstract method, the child classes should # implement this end # This method is called after the widget has been # successfully removed from another widget def removedFrom(widget) # This is an abstract method, the child classes should # implement this end # Use this widget as a container for the passed widget def add(widget) # This is an abstract method, the child classes should # implement this end def remove(widget) # This is an abstract method, the child classes should # implement this end def eql?(widget) @delegate.eql?(widget.delegate) end end end