DB-Object
view release on metacpan or search on metacpan
lib/DB/Object/Fields/Unknown.pm view on Meta::CPAN
sub STORABLE_thaw_post_processing
{
my $obj = shift( @_ );
my @keys = %$obj;
my $class = ref( $obj );
my $hash = {};
@$hash{ @keys } = @$obj{ @keys };
my $self = bless( $hash => $class );
return( $self );
}
sub THAW
{
# STORABLE_thaw would issue $cloning as the 2nd argument, while CBOR would issue
# 'CBOR' as the second value.
my( $self, undef, @args ) = @_;
my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args;
my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self );
my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {};
my $new;
# Storable pattern requires to modify the object it created rather than returning a new one
if( CORE::ref( $self ) )
{
foreach( CORE::keys( %$hash ) )
{
$self->{ $_ } = CORE::delete( $hash->{ $_ } );
}
$new = $self;
}
else
{
$new = CORE::bless( $hash => $class );
}
CORE::return( $new );
}
1;
# NOTE: POD
__END__
=encoding utf-8
=head1 NAME
DB::Object::Fields::Unknown - Unknown Field Class
=head1 SYNOPSIS
use DB::Object::Fields::Unknown;
my $f = DB::Object::Fields::Unknown->new(
table => 'some_table',
error => 'Table some_table has no such field \"some_field\".',
) || die( DB::Object::Fields::Unknown->error, "\n" );
=head1 VERSION
v0.2.0
=head1 DESCRIPTION
This class represents an unknown field. This happens when L<DB::Object::Fields> cannot find a given field used in a SQL query. Instead of returning an error (undef), it returns this object, which is then ignored when he query is formulated.
A warning is issued by L<DB::Object::Fields> when a field is unknown, so make sure to check your error output or your error log.
=head1 METHODS
=head2 as_string
Returns the error message as a regular string.
=head2 error
Sets or gets the error that triggered this new object.
This returns the error as a L<string object|Module::Generic::Scalar>
=head2 field
Sets or gets the name of the unknown field.
This returns the field name as a L<string object|Module::Generic::Scalar>
=head2 table
Sets or gets the name of the table associated with this unknown field
This returns the table name as a L<string object|Module::Generic::Scalar>
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<DB::Object::Fields>, L<DB::Object::Fields::Field>, L<DB::Object::Query>
=head1 COPYRIGHT & LICENSE
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=cut
( run in 3.181 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )