File: meta_table_metaclasstrait.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (55 lines) | stat: -rw-r--r-- 798 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w

use strict;
use Test::More 'no_plan';
use Test::Fatal;
$| = 1;



# =begin testing SETUP
BEGIN {
  package MyApp::Meta::Class::Trait::HasTable;
  use Moose::Role;
  Moose::Util::meta_class_alias('HasTable');

  has table => (
      is  => 'rw',
      isa => 'Str',
  );
}



# =begin testing SETUP
{

  # in lib/MyApp/Meta/Class/Trait/HasTable.pm
  package MyApp::Meta::Class::Trait::HasTable;
  use Moose::Role;
  Moose::Util::meta_class_alias('HasTable');

  has table => (
      is  => 'rw',
      isa => 'Str',
  );

  # in lib/MyApp/User.pm
  package MyApp::User;
  use Moose -traits => 'HasTable';

  __PACKAGE__->meta->table('User');
}



# =begin testing
{
can_ok( MyApp::User->meta, 'table' );
is( MyApp::User->meta->table, 'User', 'My::User table is User' );
}




1;