summaryrefslogtreecommitdiff
path: root/t/recipes/meta_table_metaclasstrait.t
blob: b396220de1a1f75f080d0c7bff5f070e03fc732b (plain)
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;