PropertyTable.Matcher.StringPath (property_table v0.3.4)

Copy Markdown View Source

Match logic using keys organized as hierarchical lists

Property keys that are lists look like ["first", "second", "third"]. These are intended to create a hierarchical organization of keys. Matching patterns involves checking whether the pattern is at the beginning of the key. This makes it possible to get notified on every property change where the key begins with ["first", "second"]. This is a really common use case when using hierarchically organized keys.

Two special atoms can be used:

  • :_ - match anything at this part of the list
  • :$ - match the end of the list

Summary

Functions

Check whether a pattern is valid

Check whether a property is valid

Build an ETS match-spec equivalent to matches?/2 for pattern

Returns true if the pattern matches the specified property

Functions

check_pattern(arg1)

Check whether a pattern is valid

Returns :ok on success or {:error, error} where error is an Exception struct with information about the issue.

check_property(arg1)

Check whether a property is valid

Returns :ok on success or {:error, error} where error is an Exception struct with information about the issue.

match_spec(pattern)

Build an ETS match-spec equivalent to matches?/2 for pattern

StringPath patterns translate directly into list patterns in the match-spec head: :_ is already an ETS wildcard, and the tail is left open with :_ unless the pattern ends in :"$", in which case it is [] to anchor the length. The body returns the whole row via :"$_", so PropertyTable does not need to know the row layout. Returns :error for invalid patterns.

matches?(arg1, arg2)

Returns true if the pattern matches the specified property