| 1 | package DBIx::Class::IndexSearch::Dezi; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | extends 'DBIx::Class'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Module::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | __PACKAGE__->mk_classdata( map_to => undef ); | |||||||||||||||||||||||||||
| 9 | 3 | __PACKAGE__->mk_classdata( query_parameters => {} ); | |||||||||||||||||||||||||||
| 10 | 3 | __PACKAGE__->mk_classdata( webservice_classname => undef ); | |||||||||||||||||||||||||||
| 11 | 3 | __PACKAGE__->mk_classdata( _index_fields => {} ); | |||||||||||||||||||||||||||
| 12 | 3 | __PACKAGE__->mk_classdata( _webservice => undef ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | DBIx::Class::IndexSearch::Dezi | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Version 0.05 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 3 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | package MyApp::Schema::Person; | ||||||||||||||||||||||||||||
| 29 | use base 'DBIx::Class'; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | __PACKAGE__->load_components(qw[ | ||||||||||||||||||||||||||||
| 32 | IndexSearch::Dezi | ||||||||||||||||||||||||||||
| 33 | Core | ||||||||||||||||||||||||||||
| 34 | ]); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | __PACKAGE__->table('person'); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | __PACKAGE__->add_columns( | ||||||||||||||||||||||||||||
| 39 | person_id => { | ||||||||||||||||||||||||||||
| 40 | data_type => 'varchar', | ||||||||||||||||||||||||||||
| 41 | size => '36', | ||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||
| 43 | name => { | ||||||||||||||||||||||||||||
| 44 | data_type => 'varchar', | ||||||||||||||||||||||||||||
| 45 | indexed => 1 | ||||||||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||||||||
| 47 | email => { | ||||||||||||||||||||||||||||
| 48 | data_type => 'varchar', | ||||||||||||||||||||||||||||
| 49 | size=>'128', | ||||||||||||||||||||||||||||
| 50 | indexed => 1 | ||||||||||||||||||||||||||||
| 51 | }, | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __PACKAGE__->resultset_class('DBIx::Class::IndexSearch::ResultSet::Dezi'); | ||||||||||||||||||||||||||||
| 55 | __PACKAGE__->belongs_to_index('FooClient', { server => 'http://localhost:6000', map_to => 'person_id' }); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head2 belongs_to_index ( $class, $webservice_class, \%parameters ) | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | This sets up the the webservice to use and maps the webservice index | ||||||||||||||||||||||||||||
| 62 | to the DB. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =cut | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | sub belongs_to_index { | ||||||||||||||||||||||||||
|
Subroutine
belongs_to_index: called CC=6 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 1 | my ( $class, $webservice_classname, $parameters ) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | croak 'Please specify a webservice' if !$webservice_classname; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 1 | ▶ | croak 'Please supply hostname ' if !$parameters->{server}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | croak 'Please supply map_to ' if !$parameters->{map_to}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | $class->webservice_classname( $webservice_classname ); | |||||||||||||||||||||||||||
| 73 | 1 | ▶ | $class->query_parameters( $parameters || {} ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$parameters || {}
MC/DC0%0/1
$parameters || {}
$parameters
Truth table50%1/2
A
A= $parameters
| |||||||||||||||||||||||||||||
| 74 | 1 | ▶ | $class->map_to( $parameters->{map_to} || '' ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$parameters->{'map_to'} || ''
MC/DC0%0/1
$parameters->{'map_to'} || ''
$parameters->{'map_to'}
Truth table50%1/2
A
A= $parameters->{'map_to'}
| |||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 index_key_exists ( $class, $key ) | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Find if the key exists as a registered index field. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub index_key_exists { | ||||||||||||||||||||||||||
|
Subroutine
index_key_exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 0 | my( $class, $key ) = @_; | |||||||||||||||||||||||||||
| 84 | 0 | return exists $class->_index_fields->{ $key }; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head2 register_column ( $class, $webservice_class, \%parameters ) | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Override to the register_column method. Add any "indexed" fields we | ||||||||||||||||||||||||||||
| 90 | want to search against Dezi. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||
| 93 | 5 | ▶ | sub register_column { | ||||||||||||||||||||||||||
|
Subroutine
register_column: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 5 | my ( $class, $column, $info ) = @_; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 5 | $class->next::method( $column, $info ); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 5 | ▶ | if (exists $info->{ indexed }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 1 | $class->set_index_field( $column => $info->{ indexed } ); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 set_index_field ( $class, $key, $value ) | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Setter wrapper to register an indexed field. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||
| 109 | 1 | ▶ | sub set_index_field { | ||||||||||||||||||||||||||
|
Subroutine
set_index_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 1 | my( $class, $key, $value ) = @_; | |||||||||||||||||||||||||||
| 111 | 1 | $class->_index_fields->{ $key } = $value; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 webservice ( $class ) | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Returns a webservice object. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub webservice { | ||||||||||||||||||||||||||
|
Subroutine
webservice: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( !$class->_webservice && $class->webservice_classname ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $class->_webservice and $class->webservice_classname
MC/DC0%0/2
not $class->_webservice and $class->webservice_classname
not $class->_webservice
$class->webservice_classname
Truth table0%0/3
not(A) and B
A= not $class->_webserviceB= $class->webservice_classname
| |||||||||||||||||||||||||||||
| 123 | 0 | my $webservice_classname = $class->webservice_classname; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | load $webservice_classname; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | my $webservice_obj = $webservice_classname->new(server => $class->query_parameters->{server}); | |||||||||||||||||||||||||||
| 128 | 0 | $class->_webservice($webservice_obj); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | return $class->_webservice; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Logan Bell, C<< <loganbell at gmail.com> >> | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head1 BUGS | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | Please report any bugs or feature requests to C<bug-dbix-class-indexsearch-dezi at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 141 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-IndexSearch-Dezi>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 142 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | perldoc DBIx::Class::IndexSearch::Dezi | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | You can also look for information at: | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =over 4 | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-IndexSearch-Dezi> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | L<http://annocpan.org/dist/DBIx-Class-IndexSearch-Dezi> | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | L<http://cpanratings.perl.org/d/DBIx-Class-IndexSearch-Dezi> | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | L<http://search.cpan.org/dist/DBIx-Class-IndexSearch-Dezi/> | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =back | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | Copyright 2011 Logan Bell. | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 185 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 186 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =cut | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 3 | 1; # End of DBIx::Class::IndexSearch::Dezi | |||||||||||||||||||||||||||