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

NAME

Articulate::Construction::LocationBased - Create an item based on its location

ATTRIBUTES

types

This should be a hashref mapping types to class names to be used in constructors, where a type in this case is the penultimate endpoint of locations with an even number of parts

So:

  article: Articulate::Item::Article

...would result in /article/foo or zone/public/article/foo becoming Articulate::Item::Articles but not article, zone/article, or zone/public/article.

METHODS

construct

  $self->construct( {
    location => 'zone/public/article/hello-world',
    meta     => { ... }
    content  => " ... "
  } );

Attempts to construct the item. Determines the desired class based on the mapping in the types attribute, then calls $class->new($args) on the class. Returns undef if no appropriate class found.

In the above example, $self->types->{article} would be consulted.

If the location is root or not a multiple of 2 (e.g. zone/public is even and a zone but zone/public/article is odd), returns undef.