Re: MooseX::Types coercions and $self

2010-12-19 Thread John Napiorkowski
- Original Message From: Evan Carroll m...@evancarroll.com To: moose@perl.org ML moose@perl.org Sent: Fri, December 17, 2010 3:00:06 PM Subject: MooseX::Types coercions and $self Copied from http://stackoverflow.com/q/4473327/124486 The below is not as well formatted

MooseX::Types coercions and $self

2010-12-17 Thread Evan Carroll
Copied from http://stackoverflow.com/q/4473327/124486 The below is not as well formatted: Is there anyway to get $self into a MooseX::Types coercion? I have other data in the object that I want to use to seed my coercion from a String to an Object. Alternatively, is there anything like

1.08..master breaks MooseX::Getopt DWIM coercions

2010-07-18 Thread Ævar Arnfjörð Bjarmason
2b54d2a6b7bf40c4408ffbc117f6b6d77ee35c67 by Dave Rolsky broke this DWIM MX::Getopt program: package Xailo; use 5.012; use Any::Moose; with any_moose('X::Getopt'); has args = ( documentation = Arguments for the engine class, isa = 'HashRef',

Re: 1.08..master breaks MooseX::Getopt DWIM coercions

2010-07-18 Thread Dave Rolsky
On Sun, 18 Jul 2010, Ævar Arnfjörð Bjarmason wrote: 2b54d2a6b7bf40c4408ffbc117f6b6d77ee35c67 by Dave Rolsky broke this DWIM MX::Getopt program: package Xailo; use 5.012; use Any::Moose; with any_moose('X::Getopt'); has args = ( documentation = Arguments for the engine

Re: 1.08..master breaks MooseX::Getopt DWIM coercions

2010-07-18 Thread Ævar Arnfjörð Bjarmason
On Sun, Jul 18, 2010 at 15:11, Dave Rolsky auta...@urth.org wrote: On Sun, 18 Jul 2010, Ævar Arnfjörð Bjarmason wrote: 2b54d2a6b7bf40c4408ffbc117f6b6d77ee35c67 by Dave Rolsky broke this DWIM MX::Getopt program:   package Xailo;   use 5.012;   use Any::Moose;   with any_moose('X::Getopt');

Re: 1.08..master breaks MooseX::Getopt DWIM coercions

2010-07-18 Thread Stevan Little
). No type coercions are done at all unless you specifically ask for them. Just a side note, this would have required we add a coercion on the core HashRef type, which is considered extremely bad manners since the core types are shared by all and global and should never have coercions

Re: Coercions

2010-06-18 Thread Evan Carroll
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

Re: Coercions

2010-06-18 Thread Pedro Melo
Hi, On Fri, Jun 18, 2010 at 7:21 PM, Evan Carroll e...@dealermade.com 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

Re: Coercions

2010-06-18 Thread Evan Carroll
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

Re: Coercions

2010-06-18 Thread Jesse Luehrs
, as DateTime;. In fact if I remove the where... from you working example, the tests start failing like mine did. I would like to understand why it needs the where to work. Back to the docs for me. Coercions aren't run if the input value is already of the correct type. -doy

Re: Coercions

2010-06-18 Thread Pedro Melo
added , where { ! $_-hour } and I had only subtype MyDate, as DateTime;. In fact if I remove the where... from you working example, the tests start failing like mine did. I would like to understand why it needs the where to work. Back to the docs for me. Coercions aren't run if the input

Re: Coercions

2010-06-18 Thread Jesse Luehrs
the where to work. Back to the docs for me. Coercions aren't run if the input value is already of the correct type. I though of that and thats why my original code used MyDate as a subtype of Object, not DateTime. In that case it should run, correct? No, a DateTime object will pass

Maybe[Foo] type coercions

2010-02-15 Thread Karen Etheridge
I'm having difficulty getting a type coercion to work that involves Maybes. I've looked at the deep coercion section of Moose::Manual::Types, and I'm not sure what I'm missing to get this to work? e.g. I'm running perl -MData::Dumper -MObject -MDateTime -I. -wle'my

Re: Maybe[Foo] type coercions

2010-02-15 Thread Jesse Luehrs
On Mon, Feb 15, 2010 at 04:25:54PM -0800, Karen Etheridge wrote: I'm having difficulty getting a type coercion to work that involves Maybes. I've looked at the deep coercion section of Moose::Manual::Types, and I'm not sure what I'm missing to get this to work? e.g. I'm running perl

Re: Maybe[Foo] type coercions

2010-02-15 Thread Karen Etheridge
{ not defined $_ or $_-isa('DateTime') }; ...then the object constructs properly! Hurrah! (I suspect that perhaps some of the coercions I have created are unnecessary; I'll look into that next to see if I can remove them.) doy++ :) -- Whoever acquires knowledge but does not practice

Re: Maybe[Foo] type coercions

2010-02-15 Thread mikhail maluyk
Here is slightly less verbose version package Obj; use Moose; use Moose::Util::TypeConstraints; use DateTime; use DateTime::Format::MySQL; class_type 'DateTime'; subtype 'MaybeDateTime' = as 'Maybe[DateTime]'; coerce 'MaybeDateTime' = from 'Str' = via { # check for retarded mysql

Re: Multiple coercions ?

2008-09-24 Thread Dave Rolsky
On Wed, 24 Sep 2008, Alexis Sukrieh wrote: Charles Alderman a écrit : This works for me: [...] I've just ran your test-script, and I got the same error. This is an Ubuntu 8.04 system, the Moose that comes with is 0.31, maybe this is a bug of that version? Ok, Moose _0.58_ was just

Re: Multiple coercions ?

2008-09-24 Thread Charles Alderman
be accepted as a newbie question in a moose-users list conversation. Thanks, Charles Alderman - Original Message - From: Dave Rolsky [EMAIL PROTECTED] Sent: Wed, 24 Sep 2008 10:14:49 -0500 (CDT) Re: Re: Multiple coercions ? Ok, Moose _0.58_ was just released, and you're reporting bugs

Re: Multiple coercions ?

2008-09-24 Thread Alexis Sukrieh
Charles Alderman a écrit : Perhaps if a user happens to overlook the version they're running before asking a question, it could be accepted as a newbie question in a moose-users list conversation. It's really funny how you can be flagged newbie at the first mistake you make. Indeed, I

Re: Multiple coercions ?

2008-09-24 Thread John Napiorkowski
--- On Wed, 9/24/08, John Napiorkowski [EMAIL PROTECTED] wrote: From: John Napiorkowski [EMAIL PROTECTED] Subject: Re: Multiple coercions ? To: Charles Alderman [EMAIL PROTECTED] Date: Wednesday, September 24, 2008, 12:00 PM --- On Wed, 9/24/08, Charles Alderman [EMAIL PROTECTED] wrote

Re: Multiple coercions ?

2008-09-24 Thread Karen
On Wed, Sep 24, 2008 at 11:01 AM, John Napiorkowski [EMAIL PROTECTED]wrote: course there is a downside since IRC is very unstructured and it's not searched by the big search engines, which I think hurts us PR wise. IRC also tends toward a particular culture (if I may dignify it with that

Re: Multiple coercions ?

2008-09-24 Thread Charles Alderman
to it. Thanks, Charles Alderman - Original Message - From: Alexis Sukrieh [EMAIL PROTECTED] Sent: Wed, 24 Sep 2008 17:41:02 +0200 Re: Re: Multiple coercions ? Charles Alderman a écrit : Perhaps if a user happens to overlook the version they're running before asking a question, it could

Coercions and custom type parameters

2008-07-24 Thread Charles Alderman
Hello Moose, I guess I have an enhancement idea/request. I have a parametrized ArrayRef[] of a custom type, I'd like my coercion on that type to work for any of the values in the collection. HashRef[]s should work too. Maybe Maybe[]s, but not in my example below. Would this be

Re: Coercions and custom type parameters

2008-07-24 Thread Yuval Kogman
with a parameterized type: has foo = ( isa = ArrayRef[Foo], coerce = 1, ); has a specific behavior right now, it enables only the coercions on the type ArrayRef[Foo]. If this started coercing using 'Foo's coercions we break compatibility, and deining