Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentnl/moosex-attributeindexes
Attribute Index hints on your data.
https://github.com/kentnl/moosex-attributeindexes
Last synced: 4 days ago
JSON representation
Attribute Index hints on your data.
- Host: GitHub
- URL: https://github.com/kentnl/moosex-attributeindexes
- Owner: kentnl
- License: other
- Created: 2009-08-24T12:10:39.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2017-03-09T05:33:32.000Z (over 7 years ago)
- Last Synced: 2024-06-19T15:14:34.170Z (5 months ago)
- Language: Perl
- Homepage:
- Size: 227 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
MooseX::AttributeIndexes - Advertise metadata about your Model-Representing Classes to Any Database tool.
# VERSION
version 2.000002
# SYNOPSIS
## Implementing Indexes
package My::Package;
use Moose;
use MooseX::AttributeIndexes;
use MooseX::Types::Moose qw( :all );has 'id' => (
isa => Str,
is => 'rw',
primary_index => 1,
);has 'name' => (
isa => Str,
is => 'rw',
indexed => 1,
);has 'foo' => (
isa => Str,
is => 'rw',
);## Accessing Indexed Data
package TestScript;
use My::Package;
my $foo = My::Package->new(
id => "Bob",
name => "Smith",
foo => "Bar",
);$foo->attribute_indexes
# { id => 'Bob', name => 'Smith' }## Using With Search::GIN::Extract::Callback
Search::GIN::Extract::Callback(
extract => sub {
my ( $obj, $callback, $args ) = @_;
if( $obj->does( 'MooseX::AttributeIndexes::Provider') ){
return $obj->attribute_indexes;
}
}
);## CODERef
Since 0.01001007, the following notation is also supported:
has 'name' => (
...
indexed => sub {
my ( $attribute_meta, $object, $value ) = @_;
return "$_" ; # $_ == $value
}
);Noting of course, $value is populated by the meta-accessor.
This is a simple way to add exceptions for weird cases for things you want to index that
don't behave like they should.### SEE ALSO
[`Search::GIN::Extract::AttributeIndexes`](https://metacpan.org/pod/Search::GIN::Extract::AttributeIndexes)
# AUTHORS
- Kent Fredric
- Jesse Luehrs# COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Kent Fredric .
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.