<<

NAME

DBIx::Class::FilterColumn - Automatically convert column data

SYNOPSIS

In your Schema or DB class add "FilterColumn" to the top of the component list.

  __PACKAGE__->load_components(qw( FilterColumn ... ));

Set up filters for the columns you want to convert.

 __PACKAGE__->filter_column( money => {
     filter_to_storage => 'to_pennies',
     filter_from_storage => 'from_pennies',
 });

 sub to_pennies   { $_[1] * 100 }

 sub from_pennies { $_[1] / 100 }

 1;

DESCRIPTION

This component is meant to be a more powerful, but less DWIM-y, DBIx::Class::InflateColumn. One of the major issues with said component is that it only works with references. Generally speaking anything that can be done with DBIx::Class::InflateColumn can be done with this component.

METHODS

filter_column

 __PACKAGE__->filter_column( colname => {
     filter_from_storage => 'method',
     filter_to_storage   => 'method',
 })

This is the method that you need to call to set up a filtered column. It takes exactly two arguments; the first being the column name the second being a HashRef with filter_from_storage and filter_to_storage having something that can be called as a method. The method will be called with the value of the column as the first non-$self argument.

get_filtered_column

 $obj->get_filtered_column('colname')

Returns the filtered value of the column

set_filtered_column

 $obj->set_filtered_column(colname => 'new_value')

Sets the filtered value of the column

INHERITED METHODS

DBIx::Class::Row

MULTICREATE_DEBUG, copy, delete, discard_changes, get_dirty_columns, get_from_storage, get_inflated_columns, has_column_loaded, in_storage, inflate_result, insert, insert_or_update, is_changed, is_column_changed, make_column_dirty, register_column, result_source, set_column, set_columns, set_inflated_columns, throw_exception, update_or_insert

DBIx::Class

MODIFY_CODE_ATTRIBUTES, component_base_class, mk_classaccessor, mk_classdata

DBIx::Class::Componentised

inject_base

Class::C3::Componentised

ensure_class_found, ensure_class_loaded, load_components, load_optional_class, load_optional_components, load_own_components

Class::Accessor::Grouped

get_component_class, get_inherited, get_simple, get_super_paths, make_group_accessor, make_group_ro_accessor, make_group_wo_accessor, mk_group_accessors, mk_group_ro_accessors, mk_group_wo_accessors, set_component_class, set_inherited, set_simple

<<