File Coverage

blib/lib/Fey/Meta/Attribute/FromInflator.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 23 23 100.0


line stmt bran cond sub pod time code
1             package Fey::Meta::Attribute::FromInflator;
2              
3 10     10   164 use strict;
  10         22  
  10         393  
4 10     10   58 use warnings;
  10         21  
  10         394  
5 10     10   98 use namespace::autoclean;
  10         14  
  10         103  
6              
7             our $VERSION = '0.47';
8              
9 10     10   1050 use Fey::ORM::Types qw( CodeRef );
  10         19  
  10         101  
10              
11 10     10   53789 use Moose;
  10         21  
  10         102  
12              
13             extends 'Moose::Meta::Attribute';
14              
15             has 'inflator' => (
16             is => 'ro',
17             isa => CodeRef,
18             required => 1,
19             );
20              
21             has 'raw_attribute' => (
22             is => 'ro',
23             isa => 'Fey::Meta::Attribute::FromColumn',
24             required => 1,
25             );
26              
27             sub column {
28 1     1 1 873 return $_[0]->raw_attribute()->column();
29             }
30              
31             # The parent class's constructor is not a Moose::Object-based
32             # constructor, so we don't want to inline one that is.
33             __PACKAGE__->meta()->make_immutable( inline_constructor => 0 );
34              
35             1;
36              
37             # ABSTRACT: An attribute metaclass for attributes with an inflator
38              
39             __END__
40              
41             =pod
42              
43             =head1 NAME
44              
45             Fey::Meta::Attribute::FromInflator - An attribute metaclass for attributes with an inflator
46              
47             =head1 VERSION
48              
49             version 0.47
50              
51             =head1 SYNOPSIS
52              
53             package MyApp::Song;
54              
55             has_table( $schema->table('Song') );
56              
57             for my $attr ( grep { $_->can('raw_attribute') } $self->meta()->get_all_attributes )
58             {
59             ...
60             }
61              
62             =head1 DESCRIPTION
63              
64             This attribute metaclass is used when L<Fey::ORM::Table> creates
65             attributes based on an inflator transform.
66              
67             =head1 METHODS
68              
69             This class adds a two methods to those provided by
70             C<Moose::Meta::Attribute>:
71              
72             =head2 $attr->raw_attribute()
73              
74             Returns the attribute for the raw version of this data. This is the
75             original attribute created for the column, which was renamed when the
76             inflator was declared.
77              
78             =head2 $attr->column()
79              
80             Returns the L<Fey::Column> object associated with the raw attribute.
81              
82             =head1 AUTHOR
83              
84             Dave Rolsky <autarch@urth.org>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2011 - 2015 by Dave Rolsky.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut