Fey::Meta::Method::FromSelect - A method metaclass for SELECT-based methods
version 0.47
package MyApp::Song; query average_rating => ( select => $select, bind_params => sub { $_[0]->song_id() }, );
This method metaclass allows you to generate a method based on a SELECT query and an optional bind_params subroutine reference.
SELECT
bind_params
This metaclass accepts two additional parameters in addition to the normal Moose method options.
select
This must do the Fey::Role::SQL::ReturnsData role. It is required.
This must be a subroutine reference, which when called will return an array of bind parameters for the query. This subref will be called as a method on the object which has the method. This is an optional parameter.
Note that this metaclass overrides any value you provide for "default" with a subroutine that executes the query and gets the value it returns.
This class adds a few methods to those provided by Moose::Meta::Attribute:
Moose::Meta::Attribute
Returns the query object associated with this attribute.
Returns the bind_params subroutine reference associated with this attribute, if any.
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.
selectcol_arrayref()
Dave Rolsky <autarch@urth.org>
This software is copyright (c) 2011 - 2015 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.
To install Fey::ORM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fey::ORM
CPAN shell
perl -MCPAN -e shell install Fey::ORM
For more information on module installation, please visit the detailed CPAN module installation guide.