NAME
MooX::TaggedAttributes::Cache - Extract information from a Tagged Attribute Cache
VERSION
version 0.18
SYNOPSIS
$cache = MooX::TaggedAttributes::Cache->new( $class );
$tags = $cache->tags;
DESCRIPTION
MooX::TaggedAttributes caches attribute tags as objects of this class. The user typically never instantiates objects of MooX::TaggedAttributes::Cache. Instead, they are returned by the _tags method added to tagged classes, e.g.
$cache = $class->_tags;
CLASS METHODS
new
$cache = MooX::TaggedAttributes::Cache( $class );
Create a cache object for the $class
, which must have a _tag_list
method.
METHODS
tag_attr_hash
$tags = $cache->tag_attr_hash;
Returns a reference to a read-only hash keyed off of the tags in the cache. The values are hashes which map attribute names to tag values.
For example, given:
has attr1 => ( ..., tag1 => 'foo' );
has attr2 => ( ..., tag1 => 'foo' );
has attr3 => ( ..., tag2 => 'bar' );
has attr4 => ( ..., tag2 => 'bar' );
this will be returned:
{
tag1 => { attr1 => 'foo', attr2 => 'foo' },
tag2 => { attr3 => 'bar', attr4 => 'bar' },
}
tag_hash
This is a deprecated alias for "tag_attr_hash"
tag_value_hash
$tags = $cache->tag_value_hash;
Returns a reference to a hash keyed off of the tags in the cache. The values are hashes which map tag values to attribute names (as an arrayref of names ).
For example, given:
has attr1 => ( ..., tag1 => 'foo' );
has attr2 => ( ..., tag1 => 'foo' );
has attr3 => ( ..., tag1 => 'bar' );
has attr4 => ( ..., tag1 => 'bar' );
this may be returned (the order of the attribute names is arbitrary):
{ tag1 => { foo => [ 'attr1', 'attr2' ],
bar => [ 'attr3', 'attr4' ],
},
attr_hash
$tags = $cache->tag_hash;
Returns a reference to a hash keyed off of the attributes in the cache. The values are hashes which map tag names to tag values.
tags
# return all of the tags as an array reference
$tags = $cache->tags;
# return the tags for the specified attribute as an array reference
$tags = $cache->tags( $attr );
Returns a reference to an array containing tags.
value
$value = $cache->value( $attr, $tag );
Return the value of a tag for the given attribute.
OVERLOAD
%{}
The object may be treated as a hash reference. It will operate on the reference returned by "tag_hash". For example,
keys %{ $cache };
is equivalent to
keys %{ $cache->tag_hash };
SUPPORT
Bugs
Please report any bugs or feature requests to bug-moox-taggedattributes@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=MooX-TaggedAttributes
Source
Source is available at
https://gitlab.com/djerius/moox-taggedattributes
and may be cloned from
https://gitlab.com/djerius/moox-taggedattributes.git
SEE ALSO
Please see those modules/websites for more information related to this module.
AUTHOR
Diab Jerius <djerius@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007