| 1 | # | ||||||||||
| 2 | # This file is part of MooseX-Util | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is Copyright (c) 2012 by Chris Weyl. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software, licensed under: | ||||||||||
| 7 | # | ||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||
| 9 | # | ||||||||||
| 10 | package MooseX::Util; | ||||||||||
| 11 | 4 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||
| 12 | # git description: 0.005-4-gcb0aacd | ||||||||||
| 13 | 4 | $MooseX::Util::VERSION = '0.006'; | |||||||||
| 14 | |||||||||||
| 15 | # ABSTRACT: Moose::Util extensions | ||||||||||
| 16 | |||||||||||
| 17 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | use parent 'Moose::Util'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 4 | ▶ | use Sub::Exporter::Progressive -setup => { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | exports => [ | ||||||||||
| 24 | qw{ | ||||||||||
| 25 | add_method_modifier | ||||||||||
| 26 | apply_all_roles | ||||||||||
| 27 | does_role | ||||||||||
| 28 | english_list | ||||||||||
| 29 | ensure_all_roles | ||||||||||
| 30 | find_meta | ||||||||||
| 31 | get_all_attribute_values | ||||||||||
| 32 | get_all_init_args | ||||||||||
| 33 | is_role | ||||||||||
| 34 | meta_attribute_alias | ||||||||||
| 35 | meta_class_alias | ||||||||||
| 36 | resolve_metaclass_alias | ||||||||||
| 37 | resolve_metatrait_alias | ||||||||||
| 38 | search_class_by_role | ||||||||||
| 39 | throw_exception | ||||||||||
| 40 | with_traits | ||||||||||
| 41 | }, | ||||||||||
| 42 | |||||||||||
| 43 | # and our own... | ||||||||||
| 44 | qw{ | ||||||||||
| 45 | is_private | ||||||||||
| 46 | }, | ||||||||||
| 47 | ], | ||||||||||
| 48 | groups => { default => [ ':all' ] }, | ||||||||||
| 49 | 4 | }; | |||||||||
| 50 | |||||||||||
| 51 | 4 | ▶ | use Carp 'confess'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 4 | ▶ | use MooseX::Util::Meta::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | # TODO allow with_traits() to be curried with different class metaclasses? | ||||||||||
| 56 | |||||||||||
| 57 | 2 | ▶ | sub with_traits { | ||||||||
|
Subroutine
with_traits: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 58 | 2 | my ($class, @roles) = @_; | |||||||||
| 59 | 2 | ▶ | return $class unless @roles; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 2 | return MooseX::Util::Meta::Class->create_anon_class( | |||||||||
| 61 | superclasses => [$class], | ||||||||||
| 62 | roles => \@roles, | ||||||||||
| 63 | cache => 1, | ||||||||||
| 64 | )->name; | ||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 2 | ▶ | sub is_private($) { | ||||||||
|
Subroutine
is_private: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 69 | 2 | my ($name) = @_; | |||||||||
| 70 | |||||||||||
| 71 | 2 | ▶ | confess 'is_private() must be called with a name to test!' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | unless $name; | ||||||||||
| 73 | |||||||||||
| 74 | 2 | ▶ | return 1 if $name =~ /^_/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 1 | return; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 4 | ▶ | sub find_meta { goto \&Moose::Util::find_meta } | ||||||||
|
Subroutine
find_meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | |||||||||||
| 80 | 4 | !!42; | |||||||||
| 81 | |||||||||||
| 82 | __END__ | ||||||||||