Fey::Role::ColumnLike - A role for "column-like" behavior


Fey documentation Contained in the Fey distribution.

Index


Code Index:

NAME

Top

Fey::Role::ColumnLike - A role for "column-like" behavior

VERSION

Top

version 0.40

SYNOPSIS

Top

  use Moose;

  with 'Fey::Role::ColumnLike';

DESCRIPTION

Top

Class which do this role are "column-like" . This role aggregates several other roles for the Fey::Column and Fey::Column::Alias classes.

METHODS

Top

This role provides the following methods:

$column->is_selectable()

$column->is_comparable()

$column->is_groupable()

$column->is_orderable()

These methods all return true when the $column->table() returns an object.

ROLES

Top

This class does the Fey::Role::Selectable, Fey::Role::Comparable, Fey::Role::Groupable, and Fey::Role::Orderable roles.

BUGS

Top

See Fey for details on how to report bugs.

AUTHOR

Top

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

Top


Fey documentation Contained in the Fey distribution.

package Fey::Role::ColumnLike;
BEGIN {
  $Fey::Role::ColumnLike::VERSION = '0.40';
}

use strict;
use warnings;
use namespace::autoclean;

use Moose::Role;

# This seems weird, but basically we're saying that column-like things
# do these four roles, but the implementation is different for
# column-like things (than for example, selectable things).
with(
    'Fey::Role::Selectable' => { -excludes => 'is_selectable' },
    'Fey::Role::Comparable' => { -excludes => 'is_comparable' },
    'Fey::Role::Groupable'  => { -excludes => 'is_groupable' },
    'Fey::Role::Orderable'  => { -excludes => 'is_orderable' },
);

requires '_build_id', 'is_alias';

sub _containing_table_name_or_alias {
    my $t = $_[0]->table();

    $t->is_alias() ? $t->alias_name() : $t->name();
}

sub is_selectable { return $_[0]->table() ? 1 : 0 }

sub is_comparable { return $_[0]->table() ? 1 : 0 }

sub is_groupable { return $_[0]->table() ? 1 : 0 }

sub is_orderable { return $_[0]->table() ? 1 : 0 }

1;

# ABSTRACT: A role for "column-like" behavior




__END__