Changeset 2563
- Timestamp:
- 03/02/10 00:35:33 (2 years ago)
- Location:
- Search-Query/trunk
- Files:
-
- 1 added
- 3 edited
-
Changes (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
lib/Search/Query/Dialect.pm (modified) (1 diff)
-
t/06-translate.t (added)
Legend:
- Unmodified
- Added
- Removed
-
Search-Query/trunk/Changes
r2555 r2563 40 40 expand to all defined if fields if 'default_field' is not 41 41 specified. 42 * add translate_to() method to base Dialect class. 42 43 -
Search-Query/trunk/MANIFEST
r2559 r2563 20 20 t/04-sql.t 21 21 t/05-swish.t 22 t/06-translate.t 22 23 t/pod-coverage.t 23 24 t/pod.t -
Search-Query/trunk/lib/Search/Query/Dialect.pm
r2562 r2563 144 144 } 145 145 146 =head2 translate_to( I<dialect> ) 147 148 Translate from one Dialect to another. Returns an object 149 blessed into the I<dialect> class. 150 151 =cut 152 153 sub translate_to { 154 my $self = shift; 155 my $dialect = shift or croak "Dialect required"; 156 my $query_class = Search::Query->get_dialect($dialect); 157 my $new_dialect = bless( Clone::clone($self), $query_class ); 158 my $code = sub { 159 my ( $clause, $tree, $sub, $prefix ) = @_; 160 if ( $clause->is_tree ) { 161 bless( $clause->value, $query_class ); 162 $clause->value->walk($sub); 163 } 164 }; 165 $new_dialect->walk($code); 166 return $new_dialect; 167 } 168 146 169 =head2 add_or_clause( I<clause> ) 147 170
Note: See TracChangeset
for help on using the changeset viewer.