Re: lost in subtype coersion

2011-01-28 Thread Hans Dieter Pearcey
On Fri, 28 Jan 2011 20:23:32 +0100, Jiří Pavlovský j...@getnet.cz wrote: subtype 'Subject' = as 'Str'; coerce 'Subject' = from 'Str' = via { my $sanitized = sanitize_input($_); $sanitized; }; This will never fire. Every valid Str is already a valid Subject, so no coercion

MooseX::NonMoose for Roles?

2011-01-28 Thread Zbigniew Lukasiak
Are there any sane options for building Moose::Roles out of Non Moose classes? Or maybe it is trivial? -- Zbigniew Lukasiak http://brudnopis.blogspot.com/ http://perlalchemy.blogspot.com/

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Hans Dieter Pearcey
On Fri, 28 Jan 2011 21:29:04 +0100, Zbigniew Lukasiak zzb...@gmail.com wrote: Are there any sane options for building Moose::Roles out of Non Moose classes? building roles out of classes is like building tires out of cars. Maybe you actually want a role that has an attribute that holds an

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Jesse Luehrs
On Fri, Jan 28, 2011 at 09:29:04PM +0100, Zbigniew Lukasiak wrote: Are there any sane options for building Moose::Roles out of Non Moose classes? Or maybe it is trivial? You can't just turn a class into a role - that doesn't really make sense. What you can do is use delegation instead:

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Karen Etheridge
On Fri, Jan 28, 2011 at 09:29:04PM +0100, Zbigniew Lukasiak wrote: Are there any sane options for building Moose::Roles out of Non Moose classes? Or maybe it is trivial? The thing about roles is they aren't instantiated, so you can't really do: package MyApp::Role::Foo; use base

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Karen Etheridge
On Fri, Jan 28, 2011 at 12:35:38PM -0800, Karen Etheridge wrote: However, if you imported functions from that class into your role, you can make them available in your role just the same as if you had implemented them into your role itself. ..However that only works for functions, not anything

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Zbigniew Lukasiak
On Fri, Jan 28, 2011 at 9:31 PM, Hans Dieter Pearcey h...@pobox.com wrote: On Fri, 28 Jan 2011 21:29:04 +0100, Zbigniew Lukasiak zzb...@gmail.com wrote: Are there any sane options for building Moose::Roles out of Non Moose classes? building roles out of classes is like building tires out

Re: lost in subtype coersion

2011-01-28 Thread Jiří Pavlovský
On 28.1.2011 20:28, Hans Dieter Pearcey wrote: On Fri, 28 Jan 2011 20:23:32 +0100, Jiří Pavlovskýj...@getnet.cz wrote: subtype 'Subject' = as 'Str'; coerce 'Subject' = from 'Str' = via { my $sanitized = sanitize_input($_); $sanitized; }; This will never fire. Every valid

Re: lost in subtype coersion

2011-01-28 Thread Hans Dieter Pearcey
On Fri, 28 Jan 2011 22:17:24 +0100, Jiří Pavlovský j...@getnet.cz wrote: subtype MaybeSubject = as 'Maybe[Subject]'; coerce 'MaybeSubject' = from 'Subject' = via { my $sanitized =sanitize_input($_); $sanitized; }; This doesn't make any sense to me. Otherwise I

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Zbigniew Lukasiak
On Fri, Jan 28, 2011 at 10:25 PM, Chris Prather ch...@prather.org wrote: On Fri, Jan 28, 2011 at 4:13 PM, Stevan Little stevan.lit...@iinteractive.com wrote: On Jan 28, 2011, at 4:06 PM, Zbigniew Lukasiak wrote: On Fri, Jan 28, 2011 at 9:35 PM, Karen Etheridge p...@froods.org wrote: On Fri,

Re: MooseX::NonMoose for Roles?

2011-01-28 Thread Hans Dieter Pearcey
On Fri, 28 Jan 2011 22:36:30 +0100, Zbigniew Lukasiak zzb...@gmail.com wrote: I am testing here if it could be made easy to use a library with multiple inheritance in Moose. Assuming that the additional base classes already work in a way similar to Moose Roles. If you want your classes to be

Re: lost in subtype coersion

2011-01-28 Thread Jiří Pavlovský
On 28.1.2011 22:35, Hans Dieter Pearcey wrote: On Fri, 28 Jan 2011 22:17:24 +0100, Jiří Pavlovskýj...@getnet.cz wrote: subtype MaybeSubject = as 'Maybe[Subject]'; coerce 'MaybeSubject' = from 'Subject' It actually is. = from 'Str' The first posted version was result of my random

Re: lost in subtype coersion

2011-01-28 Thread Jiří Pavlovský
On 28.1.2011 23:20, Jiří Pavlovský wrote: Well, the attribute can be unset, so what else can I do? Defaulting to empty string? I mean it can be NULL (ie undef ) from DBI