NAME

Articulate::LocationSpecification - represent a specification

DESCRIPTION

locspec ['zone', '*', 'article', 'hello-world']
locspec 'zone/*/article/hello-world' # same thing

An object class which represents a specification - like a 'pattern' or 'glob', and provides methods so that it can be compared with locations. It is similar to Articulate::Location, and stringifies to the 'file path' representation.

The main use of this is to determine whether a user has access to a resource based on rules.

FUNCTIONS

locspec

locspec is a constructor. It takes either a string (in the form of a path) or an arrayref. Either will be stored as an arrayref in the path attribute.

METHODS

path

An arrayref representing the path to the location specification. This is used for overloaded array dereferencing.

location

$locspec->location->location # same as $locspec

This method always returns the object itself.

to_file_path

Joins the contents of path on / and returns the result. This is used for overloaded stringification.

matches

locspec('/zone/*')->matches(loc('/zone/public')) # true
locspec('/zone/*')->matches(loc('/')) # false
locspec('/zone/*')->matches(loc('/zone/public/article/hello-world')) # false

Determines if the location given as the first argument matches the locspec.

matches_ancestor_of

locspec('/zone/*')->matches_ancestor_of(loc('/zone/public')) # true
locspec('/zone/*')->matches_ancestor_of(loc('/')) # false
locspec('/zone/*')->matches_ancestor_of(loc('/zone/public/article/hello-world')) # true

Determines if the location given as the first argument - or any ancestor thereof - matches the locspec.

matches_descendant_of

locspec('/zone/*')->matches_descendant_of(loc('/zone/public')) # true
locspec('/zone/*')->matches_descendant_of(loc('/')) # true
locspec('/zone/*')->matches_descendant_of(loc('/zone/public/article/hello-world')) # false

Determines if the location given as the first argument - or any descendant thereof - matches the locspec.