return $class->next::method($group => map lc, @cols);
}
-sub _register_columns {
- my ($class, @cols) = @_;
- return $class->next::method(map lc, @cols);
-}
-
sub add_columns {
my ($class, @cols) = @_;
+ $class->mk_group_accessors(column => @cols);
$class->result_source_instance->add_columns(map lc, @cols);
- $class->_mk_column_accessors(@cols);
}
sub has_a {
sub add_columns {
my ($class, @cols) = @_;
- $class->result_source_instance->add_columns(@cols);
- $class->_mk_column_accessors(@cols);
+ my $source = $class->result_source_instance;
+ $source->add_columns(@cols);
+ foreach my $c (grep { !ref } @cols) {
+ $class->register_column($c => $source->column_info($c));
+ }
}
sub _select_columns {
Accessor to the ResultSource this object was created from
+=head2 register_column
+
+ Registers a column on the class and creates an accessor for it
+
=cut
+sub register_column {
+ my ($class, $col, $info) = @_;
+ $class->mk_group_accessors('column' => $col);
+}
+
1;
=head1 AUTHORS
=head1 METHODS
-=cut
-
-sub _mk_column_accessors {
- my ($class, @cols) = @_;
- $class->mk_group_accessors('column' => grep { !ref } @cols);
-}
-
=head2 add_columns
__PACKAGE__->add_columns(qw/col1 col2 col3/);