GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::DBI::LAZYINFLATE (3)

.ds Aq ’

NAME

Class::DBI::LazyInflate - Defer Inflating Of Columns Until They Are Used

CONTENTS

SYNOPSIS



  package MyData;
  use base qw(Class::DBI);
  use Class::DBI::LazyInflate;
  use DateTime;
  use DateTime::Format::MySQL;

  __PACKAGE__->has_lazy(
    lastmod, DateTime,
    inflate => sub { DateTime::Format::MySQL->parse_datetime(shift) },
    deflate => sub { DateTime::Format::MySQL->format_datetime(shift) },
  );

  my $obj = MyData->retrieve($key); # lastmod is not inflated yet
  $obj->lastmod()->year();          # now it is.

  $obj->lastmod(DateTime->now());

  # Specify another Class::DBI type as a column:
  __PACKAGE__->has_lazy(cdbi_field => MyData);



DESCRIPTION

Class::DBI::LazyInflate is a utility class that allows you to create DBI columns that only inflate to an object when it is required. When a row is fetched, columns specified via has_lazy() is wrapped by Data::Lazy, such that it is inflated only when the column is actually used.

As seen in the SYNOPSIS section, one application of this class is for columns that inflate to objects that are costly to create, such as DateTime. Class::DBI::LazyInflate allows you defer materialization of such objects until when you really need it.

METHODS

has_lazy($col, CW$class, inflate => ..., deflate => ...)

has_lazy() declares that column is to be inflated lazily, and is installed to the calling package’s namespace upon call to use Class::DBI::LazyInflate. The arguments are exactly the same as has_a().

If inflate is not specified, it will lazily perform the default inflate procedure that Class::DBI uses.

AUTHOR

Copyright (c) 2004-2005 Daisuke Maki <dmaki@cpan.org>

SEE ALSO

Class::DBI Data::Lazy

For DateTime objects, you may also be interested in DateTime::LazyInit.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::DBI::LAZYINFLATE (3) 2005-10-18

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.