Dave Rolsky > Fey-ORM-0.44 > Fey::Meta::Method::FromSelect

Download:
Fey-ORM-0.44.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Stalled  1
View/Report Bugs
Module Version: 0.44   Source   Latest Release: Fey-ORM-0.46

NAME ^

Fey::Meta::Method::FromSelect - A method metaclass for SELECT-based methods

VERSION ^

version 0.44

SYNOPSIS ^

  package MyApp::Song;

  query average_rating => (
      select      => $select,
      bind_params => sub { $_[0]->song_id() },
  );

DESCRIPTION ^

This method metaclass allows you to generate a method based on a SELECT query and an optional bind_params subroutine reference.

OPTIONS ^

This metaclass accepts two additional parameters in addition to the normal Moose method options.

Note that this metaclass overrides any value you provide for "default" with a subroutine that executes the query and gets the value it returns.

METHODS ^

This class adds a few methods to those provided by Moose::Meta::Attribute:

$attr->select()

Returns the query object associated with this attribute.

$attr->bind_params()

Returns the bind_params subroutine reference associated with this attribute, if any.

WANTARRAY ^

The generated method will use DBI's selectcol_arrayref() method to fetch data from the database. If called in a list context, it returns all the values it retrieves. In scalar context, it returns just the first value.

AUTHOR ^

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2011 by Dave Rolsky.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: