- Original Message
> From: Evan Carroll
> To: "moose@perl.org ML"
> 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 form
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
Class::MOP
e Getopt::Long for details on
this feature). 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
On Sun, Jul 18, 2010 at 15:11, Dave Rolsky 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');
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
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',
e { ! $_->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
> >>
;
>>
>> hmms... I had code like that in a previous version but could not get
>> it to work. The difference is that you added ", where { ! $_->hour }"
>> and I had only "subtype MyDate, as DateTime;".
>>
>> In fact if I remove the "where
> Coercions aren't run if the input value is already of the correct type.
Since .72
--
Evan Carroll
System Lord of the Internets
et
> it to work. The difference is that you 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 value is already of the correct type.
-doy
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
> tim
> 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 ti
Hi,
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've uploaded a minimal set of perl files (incl. tests and test
output) to reproduce the problem:
http://gist.github.com/443949
git clone git://gist.github
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 mysq
ition. However, I see that I'm dereferencing $_ before checking its
definedness, so if I switch to:
=> where { 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&
Excerpts from Jesse Luehrs's message of Mon Feb 15 19:31:24 -0500 2010:
> I'm not sure what problem you're having, since you didn't post the
> error message, but you probably need the attribute definition to happen
> after the types are defined... pretty sure this would assume you have a
> class na
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
>
>
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
$o=Object->new(date=>"-
the version they're running
before asking a question, it could 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: Multipl
it and
contribute 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
b
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
--- 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
> ---
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 tot
could 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
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 releas
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?
Alexis.
- Original Message -
From: Alexis Sukrieh <[EMAIL PROTECTED]>
Sent: Wed, 24 Sep 2008 16:57:11 +0200
Re: Re: Multiple coercions ?
Alexis Sukrieh a écrit :
Find attached the test script:
Hmm, sorry, looks like the attachment gets droped by the ML.
Here is the pure paste:
$ cat multiple_
x27;, $day);
return "${year}-${mon}-${day} ${hour}:${min}:${sec}";
}
# Types & Coercions
use Moose::Util::TypeConstraints;
subtype 'Date'
=> as 'Str'
=> where { /^\d\d\d\d-\d\d-\d\d$/ };
subtype 'DateTime'
=> as 'Str'
Charles Alderman a écrit :
Now - and that's where the issue gets in the scene - if I add another
coercion for the DateTime subtype, but from another source, it won't
work :
Are you sure you haven't defined the coercion to "DateTime" from "Int"
somewhere else?
Sure.
Find attached the test
Now - and that's where the issue gets in the scene - if I add another
coercion for the DateTime subtype, but from another source, it won't
work :
Are you sure you haven't defined the coercion to "DateTime" from "Int"
somewhere else?
This works for me:
{
package Foo;
use Moose;
Hello there,
I'm a bit puzzled by something I found when hacking on Coat and I'd like
to have your point of view on this.
Let's say we have the folloiwng types:
subtype 'Date'
=> as 'Str'
=> where { /^\d\d\d\d-\d\d-\d\d$/ };
subtype 'DateTime'
=> as 'Str'
=> where
- 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]",
distance?
Declaring an attribute 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 star
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
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 worthwhi
40 matches
Mail list logo