On Fri, Jun 18, 2010 at 09:41:40PM +0100, Pedro Melo wrote:
> Hi,
>
> On Fri, Jun 18, 2010 at 8:35 PM, Jesse Luehrs wrote:
> > On Fri, Jun 18, 2010 at 08:14:28PM +0100, Pedro Melo wrote:
> >> On Fri, Jun 18, 2010 at 7:44 PM, Evan Carroll wrote:
> >> > Actually you can do this with MX::Types too:
Hi,
On Fri, Jun 18, 2010 at 8:35 PM, Jesse Luehrs wrote:
> On Fri, Jun 18, 2010 at 08:14:28PM +0100, Pedro Melo wrote:
>> On Fri, Jun 18, 2010 at 7:44 PM, Evan Carroll wrote:
>> > Actually you can do this with MX::Types too:
>> >
>> > use MooseX::Types -declare => [qw( MyDate DateTime )];
>> > u
> Coercions aren't run if the input value is already of the correct type.
Since .72
--
Evan Carroll
System Lord of the Internets
On Fri, Jun 18, 2010 at 08:14:28PM +0100, Pedro Melo wrote:
> Hi,
>
>
> On Fri, Jun 18, 2010 at 7:44 PM, Evan Carroll wrote:
> > Actually you can do this with MX::Types too:
> >
> > use MooseX::Types -declare => [qw( MyDate DateTime )];
> > use MooseX::Types::Moose qw( Str Int HashRef Object );
Hi,
On Fri, Jun 18, 2010 at 7:44 PM, Evan Carroll wrote:
> Actually you can do this with MX::Types too:
>
> use MooseX::Types -declare => [qw( MyDate DateTime )];
> use MooseX::Types::Moose qw( Str Int HashRef Object );
> use DateTime;
>
> class_type DateTime, { class => 'DateTime' };
>
> subtyp
For reference, I put a working example up at
http://gist.github.com/443985/912c7376cf56d8f1b7fe1b6b5294ea5eef7f06c6
--
Evan Carroll
System Lord of the Internets
Actually you can do this with MX::Types too:
use MooseX::Types -declare => [qw( MyDate DateTime )];
use MooseX::Types::Moose qw( Str Int HashRef Object );
use DateTime;
class_type DateTime, { class => 'DateTime' };
subtype MyDate, as DateTime, where { ! $_->hour };
Or, whatever makes your subtyp
I see those tests are a waste. The deal is this then:
subtype MyDate, as Object;
What you need to do is subclass DateTime, and make subtype MyDate
require that type, then coerce from type DateTime.
--
Evan Carroll
System Lord of the Internets
Hi,
On Fri, Jun 18, 2010 at 7:21 PM, Evan Carroll wrote:
>> I'm trying to create a Date type, and one of the coercions I wanted
>> was from a DateTime object. I can't get it to work.
>
> I believe your problem is UTC vs floating. ->from_epoch asserts the
> time_zone is UTC unless provided. All ot
> I'm trying to create a Date type, and one of the coercions I wanted
> was from a DateTime object. I can't get it to work.
I believe your problem is UTC vs floating. ->from_epoch asserts the
time_zone is UTC unless provided. All other calls to new are
implicitly floating time_zones.
--
Evan Car
- Original Message -
From: Yuval Kogman <[EMAIL PROTECTED]>
Sent: Thu, 24 Jul 2008 23:27:11 +0300
Re: Re: Coercions and custom type parameters
Declaring an attribute with a parameterized type:
has foo => (
isa => "ArrayRef[Foo]",
On Thu, Jul 24, 2008 at 16:16:28 -0400, Charles Alderman wrote:
> I guess that if you're trying to prevent this as an action at a distance,
> 'deep_coerce' wouldn't really be acceptable either. Wouldn't that just be
> a more explicit warning of an action at a distance?
Declaring an attribute wi
PROTECTED]>
Sent: Thu, 24 Jul 2008 22:37:45 +0300
Re: Re: Coercions and custom type parameters
This has been brought up before, the short story is 'coerce => 1'
may introduce action at a distance, so we decided that if at all
this should be 'deep_coerce => 1'.
A
This has been brought up before, the short story is 'coerce => 1'
may introduce action at a distance, so we decided that if at all
this should be 'deep_coerce => 1'.
At any rate, this is a little trickier than it sounds, but if Stevan
approves deep_coerce => 1 feel free to commit this as a todo te
14 matches
Mail list logo