| Fey-ORM documentation | Contained in the Fey-ORM distribution. |
Fey::Object::Policy - An object representing a specific policy
version 0.43
This class provides the non-sugar half of Fey::ORM::Policy. It's probably not interesting unless you're interested in the guts of how Fey::ORM works.
This class accepts the following methods:
Stores a transform as declared in Fey::ORM::Policy
Given a Fey::Column, returns the first transform (as a hash
reference) for which the matching sub returns true.
Returns all of the transforms for the policy.
Returns the naming sub for has_one() methods. Defaults to:
sub { lc $_[0]->name() }
Sets the naming sub for has_one() methods.
Returns the naming sub for has_many() methods. Defaults to:
sub { lc $_[0]->name() }
Sets the naming sub for has_many() methods.
Dave Rolsky <autarch@urth.org>
This software is copyright (c) 2011 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.
| Fey-ORM documentation | Contained in the Fey-ORM distribution. |
package Fey::Object::Policy; BEGIN { $Fey::Object::Policy::VERSION = '0.43'; } use strict; use warnings; use namespace::autoclean; use Fey::ORM::Types qw( ArrayRef CodeRef HashRef ); use List::Util qw( first ); use Moose; use MooseX::StrictConstructor; use MooseX::SemiAffordanceAccessor; has '_transforms' => ( traits => ['Array'], is => 'ro', isa => ArrayRef[HashRef], default => sub { [] }, init_arg => undef, handles => { add_transform => 'push', transforms => 'elements', }, ); has 'has_one_namer' => ( is => 'rw', isa => CodeRef, default => \&_dumb_namer, required => 1, ); has 'has_many_namer' => ( is => 'rw', isa => CodeRef, default => \&_dumb_namer, required => 1, ); sub transform_for_column { my $self = shift; my $column = shift; return first { $_->{matching}->($column) } $self->transforms(); } sub _dumb_namer { return sub { lc $_[0]->name() }; } __PACKAGE__->meta()->make_immutable(); 1; # ABSTRACT: An object representing a specific policy
__END__