The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Articulate::LocationSpecification - represent a specification

DESCRIPTION

  new_location_specification ['zone', '*', 'article', 'hello-world']
  new_location_specification '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 (e.g. Articulate::Authorisation::LocationBased).

FUNCTIONS

new_location_specification

new_location_specification 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.

ATTRIBUTE

path

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

METHODS

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

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

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

matches_ancestor_of

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

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

matches_descendant_of

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

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

SEE ALSO