NAME
Articulate::Flow::ContentType - case switching for content_type
CONFIGURATION
- class: Articulate::Flow::ContentType
args:
where:
'text/markdown':
- Articulate::Enrichment::Markdown
otherwise:
- SomeOther::Enrichment
DESCRIPTION
This provides a convenient interface to a common branching pattern. When performing actions like enrich
and augment
, a developer will typically want to make some processes dependant on what type of content is stored in the item.
Rather than having to write a 'black box' provider every time, this class provides a standard way of doing it.
METHODS
enrich
$self->enrich( $item, $request );
$self->process_method( enrich => $item, $request );
augment
$self->augment( $item, $request );
$self->process_method( augment => $item, $request );
process_method
$self->process_method( $verb, $item, $request );
Goes through each of the keys of $self->where
; if the key is equal to the content_type
of $item
, then instantiates the value of that key and performs the same verb on the arguments.
If none of the where clauses matched, the otherwise provider, if one is specified, will be used.
An item's content_type
is retrieved from meta.schema.core.content_type
.