# enaml.core.pattern

Classes

`Pattern` | A declarative object that represents a pattern object.

class enaml.core.pattern.Pattern(parent=None, **kwargs)

  Bases: `Declarative`

  A declarative object that represents a pattern object.

  The Pattern class serves as a base class for other classes such as Looper and Conditional, where the compiler nodes for the hierarchy are used to modify the standard behavior of creating children.

  Creating a Pattern without a parent is a programming error.

  __intercepts_child_nodes__ = True

    Single to the compiler that this class handles child creation.

  pattern_nodes

    Storage for the collected pattern nodes. This is used directly by subclasses and should not be manipulated by user code.

  initialize()

    A reimplemented initialization method.

  destroy()

    A reimplemented destructor.

    The pattern will destroy all of the pattern items unless the parent object is in the process of being destroyed.

  child_node_intercept(nodes, key, f_locals)

    Add a child subtree to this pattern.

    This method changes the default behavior of the runtime. It stores the child nodes and the locals mapping until the object is initialized, at which point the nodes will be called to create the pattern items.

    Parameters:

      - nodes (list) – A list of compiler nodes containing the information required to instantiate the children.

      - key (object) – The scope key for the current local scope.

      - f_locals (mapping or None) – A mapping object for the current local scope.

  pattern_items()

    Get a list of the items created by the pattern.

    This method must be implemented by subclasses to return a flat list of Declarative instances created by the subclass.

    Returns:

      result – A new list of Declarative objects owned by the pattern.

    Return type:

      list

  refresh_items()

    Refresh the items of the pattern.

    This method must be implemented by subclasses to refresh the items of the pattern.