Skip Menu |

This queue is for tickets about the MooseX-Types CPAN distribution.

Report information
The Basics
Id: 88650
Status: resolved
Priority: 0/
Queue: MooseX-Types

People
Owner: Nobody in particular
Requestors: andy [...] broadbean.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.37
Fixed in: (no value)



Subject: Support inlined packages?
Hi, https://metacpan.org/source/PNU/DBIx-Class-Migration-0.040/lib/DBIx/Class/Migration/Types.pm defines some types in an inlined package. This used to work when MooseX::Types was using Class::MOP. v0.37 throws a runtime error saying it can't find the package. MooseX::Types::Combine tries to load that package using Module::Runtime. The package doesn't exist in its own file so it fails hence the error. What do you think about supporting this? You could use use_package_optimistically() instead of use_module() or check if the module is already loaded. I can create a pull request if it helps
Subject: 25_inline_packages.t
use strict; use warnings; use Test::More; pass("Loaded types from an inlined package"); done_testing(); package Types; use base 'MooseX::Types::Combine'; __PACKAGE__->provide_types_from('InlinedPackageTypes'); package InlinedPackageTypes; use MooseX::Types -declare => [ 'InlinedType' ]; 1;
Subject: inline-package-support.diff
diff --git a/lib/MooseX/Types/Combine.pm b/lib/MooseX/Types/Combine.pm index cc85815..3d95c84 100644 --- a/lib/MooseX/Types/Combine.pm +++ b/lib/MooseX/Types/Combine.pm @@ -88,6 +88,8 @@ sub provide_types_from { sub _check_type_lib { my ($class, $lib) = @_; + return if $lib->can('type_names'); # already loaded + use_module($lib); die "Cannot use $lib in a combined type library, it does not provide any types"
On Fri Sep 13 05:24:24 2013, andyjones wrote: Show quoted text
> Hi, > > https://metacpan.org/source/PNU/DBIx-Class-Migration- > 0.040/lib/DBIx/Class/Migration/Types.pm defines some types in an > inlined package.
Right, so that means that you need to do - $INC{'My/Class.pm'} = __FILE__; in the definition to tell perl that the inlined package is a complete implementation and you don't need to load the file. Once you've fixed this bug, your code will work fine still.