NAME
DBIx::Class::Numeric - add helper methods for numeric columns
SYNOPSIS
package MyApp::Schema::SomeTable;
use base 'DBIx::Class';
__PACKAGE__->load_components(qw/Core Numeric/); # Load the Numeric component
__PACKAGE__->add_columns( qw/primary_id some_string num_col1 num_col2/ );
__PACKAGE__->numeric_cols(qw/num_col1 num_col2/); # List any cols that need the extra functionality
# ... meanwhile, after reading a record from the DB
$row->increase_num_col1(5); # Add 5 to num_col1
$row->decrease_num_col2(9); # Subtract 9 from num_col2
$row->adjust_num_col1(-5); # Subtract 5 from num_col1 # (can be positive or negative, as can increase/decrease... # adjust is just a clearer name...)
$row->increment_num_col1; # Increment num_col1
$row->decrement_num_col2; # Decrement num_col2
DESCRIPTION
A simple DBIx::Class component that adds five methods to any numeric columns in a schema class.
METHODS
numeric_cols(@cols)
Call this method as you would add_columns(), and pass it a list of columns that are numeric. Note, you need to pass the column names to add_columns() *and* numeric_cols().
increase_*, decrease_*, increment_*, decrement_*, adjust_*
These 5 self-explanatory methods are added to your schema class for each column you pass to numeric_cols()
AUTHOR
Sam Crawley (Mutant) - mutant dot nz at gmail dot com
LICENSE
You may distribute this code under the same terms as Perl itself.