Re: Setting delegated attributes in constructors

2018-02-13 Thread Buddy Burden
Merlyn, I guess the problem here is that Moose doesn't really call the accessors in the constructor but just uses some shortcut to copy the constructor parameters to the object. While I fully admit that I've not been following this discussion closely, whenever I've seen a statement such as thi

Re: custom accessor_metaclass override of _inline_store (Moose 1 to 2)

2016-03-23 Thread Buddy Burden
Toby, All these attributes to which I want to apply this trigger share the same trait, so there's a logical association between the two. Is there a way I can utilise this, so I don't have to define 'trigger => ' for every attribute which uses this trait, i.e. have a trigger built into an a

Re: Replacement for MooseX::Declare?

2015-09-29 Thread Buddy Burden
Matija, it says that "Support for using Function::Parameters to handle method signatures is likely to be dropped" https://metacpan.org/pod/Moops#Planned-Changes Does this means that I have to use method change_job { my ( $employer,$title ) = @_; } instead of method chang

Re: 'around' method modifier does not seem to work

2015-08-08 Thread Buddy Burden
Marcos, around 'sequence' => sub { my $orig = shift; my $self = shift; if ( @_ == 1 ) { my $sequence = _get_parsed_sequence( shift ); return $self->$orig( $sequence ); } else { return $self->{sequence}; } }; I get it to work. Not a ve

Re: Moose n00b question about writer / reader

2015-04-19 Thread Buddy Burden
Andrew, I want to create a class that has some attributes. However, there’s some logic that needs to be executed when setting values on these attributes. In some cases, I’ll need to throw an error like “you can’t set that value on this object attribute”, I also need to be able to modify the valu

Re: Role delegation (sort of)

2013-07-05 Thread Buddy Burden
Jesse, There's nothing stopping you from using delegation in this case either. All you have to do is make the object you delegate to consume both your API role and MooseX::Storage, and then have the rest of your code just use the API role. Using excludes is basically always the wrong answer. Fo

Re: Role delegation (sort of)

2013-07-04 Thread Buddy Burden
Ben, Create your role Persistent which requires a number of the methods from MooseX::Storage and supplies the API that you want. If $storage is something that does MooseX::Storage, you can then turn it into a Persistent thing with: Persistent->meta->apply($storage); But this is hiding the im

Role delegation (sort of)

2013-07-04 Thread Buddy Burden
Guys, Okay, so if I want to create a class which fulfills the interface of another class, I would use inheritance. But if I want to create a class which specifically does _not_ fulfill the interface of another class--let's say I want to create a [facade pattern|http://en.wikipedia.org/wiki/F

Re: moose and pod

2012-12-18 Thread Buddy Burden
Maurice, > It seems some people like inherited stuff > (including roles) to be listed in each class that inherits stuff and others > like it only in the class which defines stuff. It seems to me that the problem with listing methods (and/or attributes) that you inherit is that, if the base class

Re: coercing method arguments in MooseX::Declare

2012-10-05 Thread Buddy Burden
shtil, Sorry; I just noticed that you hadn't gotten a response to this yet: > # How to specify coerce =>1 here ? > method add_target (Target $target! ) { > > > } Try: method add_target (Target $target does coerce) { } The default signature processing for MXD is MooseX::Method::Signatur

Re: MooseX-Method-Signatures-0.37 install failure on Strawberry Perl 5.14.2.1

2012-02-11 Thread Buddy Burden
Gabor, > #   Failed test 'Sane error message for syntax error' > #   at t/errors.t line 11. > #                   'Can't use an undefined value as an ARRAY > reference at C:/strawberry/perl/site/lib/Eval/Closure.pm line 119. > # Compilation failed in require at (eval 17) line 1. > # BEGIN failed--

Re: Incompatibility between Test::Command and System::Command?

2012-02-01 Thread Buddy Burden
John, > Patches, or even just feature requests of the form "when I do this, it > should do that", gratefully received at the 'Issues' section of your > friendly neighborhood Git::Wrapper Github repo: > > I really appreciate that. I just want to ma

Re: Incompatibility between Test::Command and System::Command?

2012-01-31 Thread Buddy Burden
Grzegorz, > In mean time i've made a hack which is "fixing" this hack: > > open(my $NULL, '>', '/dev/null'); > my $ORIGINAL_STDOUT = select($NULL); > > <... do what you need using System::Command and/or Git::Repository ...> > > select($ORIGINAL_STDOUT); > close($NULL); Finally getting back to thi

Re: "automatically" wrapping methods.

2012-01-15 Thread Buddy Burden
Peter, > However, I would prefer an interface where the signature is specified in the > prototype slot of the sub: > >     sub foo (bar, baz) { ... } Why don't you just use one of the signatures modules? E.g., #! /usr/bin/perl use MooseX::Declare; use Method::Signatures::Modifiers; class Foo

Re: Incompatibility between Test::Command and System::Command?

2012-01-04 Thread Buddy Burden
Mark, > Something like: > >   `git ls-tree --name-only -r HEAD | grep $directory`; > > from the root of the repo? That's assuming I _have_ the root of the repo and want to see if a directory I have is in there. What I want is, given _only_ a directory, to see if said directory is part of a(ny) G

Re: Incompatibility between Test::Command and System::Command?

2012-01-04 Thread Buddy Burden
Grzegorz, > I've noticed the same thing, but with STDOUT and with Test::Output > and/or FastCGI. > > There is a hack in System::Command for Catalyst which causes this. > See https://rt.cpan.org/Public/Bug/Display.html?id=73614 Ah, good call on the RT ticket. I've added a comment there as well. I

Incompatibility between Test::Command and System::Command?

2012-01-03 Thread Buddy Burden
Guys, Okay, I got it down to this, but I can't seem to narrow it down further. Time to call in the big guns.(*) This code: #! /usr/bin/perl use Test::More 0.88; use Test::Command; stderr_like(q{ perl -le 'print STDERR "STDERR points to ", readlink "/proc/self/fd/2"' }, qr/STDERR point

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-27 Thread Buddy Burden
Chris, > You can use the fact that the attribute's default is called as a method on > the instance itself to look up the associated metaclass, then the attribute, > then the type constraint...  At that point the type constraint, if any, > should exist. :) Wait ... what? the default sub is called

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-27 Thread Buddy Burden
Sorry for the holidayus interruptus, guys! Just getting back to this ... Edward, > You also have all the options passed in creation.  As long as you are not > using attribute override (has +), you have what you need, I think? Something > like this: Well, yes, but that's what I was saying in fo

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
On Thu, Dec 22, 2011 at 3:51 PM, Edward Allen wrote: > As long as you document what you are doing so that the poor sap who has to > maintain your code after you win the lottery can figure it out, I say go for > it!  Wrapping _process_options is time honored, convenient, and an absolute > must tech

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
Chris, > I've always had the opinion that if I'm writing metaclass traits, then by > definition I'm changing the private parts to accomplish my task.  Which to > me makes it far more acceptable than, say, poking at _process_options() from > outside of Moose::Meta::Attribute.  That is, I'm not acce

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
Chris, > Just to throw a third approach in... The more the merrier. :-) > Given that this is easily achievable with builders/defaults (if you're > willing to set them on every attribute), I'd probably just wrap the > Moose::Meta::Attribute::_process_options() method (via an attribute trait) > al

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
Todd, > Not quite... We're not changing the default metaclass for everything, but > rather applying a metarole to the metaclass of the consuming class. (I think > that's how it goes -- I'm still not sure of the correct terminology.) Yes, true, but my thinking goes (and I freely admit I could be w

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
Guys, I'm still experimenting here, but I had a couple of questions. ealleniii, I like your solution; very clever, particularly where you install the bulder sub as a default instead of a builder, which neatly gets around the problem that a builder has to be the name of a method of the class. B

Re: Trying to create an attribute trait that prompts for a value if none specified

2011-12-22 Thread Buddy Burden
Guys, Thanks to everyone for the suggestions so far! (One on-list and one off-.) I'll take some time to digest these and I'm sure I'll be able to put something together.             -- Buddy

Trying to create an attribute trait that prompts for a value if none specified

2011-12-21 Thread Buddy Burden
Guys, Okay, basically what I want is just what the subject says: you might declare your attribute something like so: has value => ( traits => [qw< Promptable >], is => 'rw', isa => 'Int', prompt => 'Please enter a value:' ); then, for each instance, if you provide a value in new(), that's th

Re: determining if class already exists

2011-06-26 Thread Buddy Burden
It's in Class::MOP. There's is_class_loaded and also load_class. HTH. On Jun 26, 2011 7:32 AM, "Mark Wood-Patrick" wrote:

Re: Moose Type Constraints violations to warnings?

2011-06-10 Thread Buddy Burden
Ovid, On Fri, Jun 10, 2011 at 3:06 AM, Ovid wrote: > When I declare a parameter as follows: > > >     has 'some_val' => ( >         is  => 'rw', >         isa => 'Int', >     ); > > Later if I do $object->some_value("foobar"), it blows up with a stack trace > because of the type constraint viola

Re: Type checking for roles

2011-03-23 Thread Buddy Burden
Ovid, > I'm following but I have a new job, a new country, a relatively new wife and > a very new baby. Thus, I skim a lot of things, but I can't really dig in too > deeply. Sorry 'bout that (hence, my relative lack of participation in the > Perl community lately). Okay, no worries. RL takes

Re: Type checking for roles

2011-03-21 Thread Buddy Burden
On Thu, Mar 17, 2011 at 6:07 PM, Buddy Burden wrote: > Moosites, > > I'm working on adding type checking to Method::Signatures, and I want > it to be able to handle roles.  So, if I say: > >    method foo (Blargy $bar) > > and Blargy is a role, I want it to verify

Type checking for roles

2011-03-17 Thread Buddy Burden
Moosites, I'm working on adding type checking to Method::Signatures, and I want it to be able to handle roles. So, if I say: method foo (Blargy $bar) and Blargy is a role, I want it to verify that $bar is an object whose class composes the Blargy role. I believe that's as simple as checkin

Re: MooseX::Declare without MooseX::Method::Signatures

2011-02-22 Thread Buddy Burden
Piers, Hey, thanks for the personal response. > I used: > >    use MooseX::Declare; >    class Foo { >        use Method::Signatures::Simple name => 'simple_method' >    } > > Which buys me the full fat MXD 'method' implementation for where I need > fancy stuff, and a 'simple_method' keyword for

MooseX::Declare without MooseX::Method::Signatures

2011-02-18 Thread Buddy Burden
Guys, I'm trying to figure out if I can turn off just the MXMS part of MXD (i.e. lose the "method" keyword) ... what I'm trying to do is to use Method::Signatures instead, possibly augmenting/extending it to use MooseX::Params::Validate for the type checking. (If anyone really wants to know why,

Re: Inheritance not working for some weird reason.

2011-02-03 Thread Buddy Burden
doy, Sorry for the late reply; $work just kicking my ass a bit. > I just released circular::require to CPAN to help diagnose these kinds > of issues: > http://search.cpan.org/~doy/circular-require-0.01/lib/circular/require.pm Wow ... you cranked that out super-fast! I did take a look at it and

Re: Inheritance not working for some weird reason.

2011-01-25 Thread Buddy Burden
Nick, > Bad news (well, not really bad news) next. You must take extra special > care NOT to require/import/use the MXD class WHILE they are going > through the compile stage. Basically you end up with a circular compile > cycle of the class, through one of its use statements. The process is > not

Re: Overhead of using MooseX::Declare

2010-10-22 Thread Buddy Burden
Guys, > A more relevant > comparison and valuable discussion would be the difference in overhead > between MX::Declare and plain old Moose. Also, am I incorrect in believing that _all_ the overhead of MX::Declare is in the startup? For instance, using it in a mod_perl environment (which I am her

Re: Bizarre error with Moose, Mason, and Perl 5.12

2010-10-05 Thread Buddy Burden
Nicholas, Thanx to you too for the quick response. > This really has nothing to do Moose per se, but it is a problem with > MooseX::Declare. Back at 5.11.2 Zefram introduced changes into perl core that > basically broke Devel::Declare modules. The work around is to use ugly K&R > brace style.

Re: Bizarre error with Moose, Mason, and Perl 5.12

2010-10-05 Thread Buddy Burden
Jesse, Thanks for the super-quick response! I got busy with $work for a bit, but I did pass on your wisdom immediately. > As far as I'm aware, this is a bug with MooseX::Method::Signatures and > perl 5.12, in that the parsing for methods doesn't work quite right if > the initial brace for that m

Bizarre error with Moose, Mason, and Perl 5.12

2010-09-28 Thread Buddy Burden
Guys, Okay, this has been bugging us for a while now, because we've been wanting to do some QA on Perl 5.12 with an eye to switching our production environment to it at some point, but this error has stopped us. But I've just now had the opportunity to whittle it down to something small enough fo

Re: Can't locate 0.pm?

2010-05-25 Thread Buddy Burden
Tomas, > Something is saying: > > Class::MOP::load_class($_) for qw/Class1 Class2 Class3/; > > As $_ is aliased (being a special variable), then stamping on it causes bad > things to happen. > > Loading one of your classes (or a class that it needs) ends up stamping on > $_, ergo causing everythin

Re: Can't locate 0.pm?

2010-05-25 Thread Buddy Burden
Chris, >> perl -MMooseX::Declare -le 'no strict qw; our $ver = >> "${_}::VERSION" and print "$_ :: $$ver" foreach qw> MooseX::Declare Class::MOP Devel::Declare>' >> Moose :: 1.01 >> MooseX::Declare :: 0.33 >> Class::MOP :: 0.98 >> Devel::Declare :: 0.005011 > Same is not equivalent to "up to date

Re: Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Chris, > Somewhere in the myriad of class loaders and syntax modifiers > something is passing '0' to CMOP::load_class. It *looks* like this is > coming from Devel::Declare (the thing MooseX::Declare uses to sugar up > the syntax) getting confused when it parses the > Company::CompanyBusinessModel

Re: Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Chris, > Not sure what part of the previous responses by Nick and Chris didn't make > sense, but they were fairly clear to me. As it happens, no part of their responses were unclear, and I did in fact reply with code. However, what I apparently did _not_ do is include the list on those replies

Re: Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Chris, > Especially /home/buddy/proj/rent.com/lib/Company/CompanyBusinessModel.pm > line 16 Ah. Well, that's just the class declaration for that class (although IME the line numbers in Moose error messages don't always line up with the actual line numbers). Here's the line with its surrounding

Re: Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Nick, > Can we see some code please? Well, I didn't include any code because it doesn't seem to be happening in the code on my side ... the argument looks fine well into the depths of Class::MOP. But here's my version of load_class: # load_class is a bit tougher, because we want to untaint w

Re: Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Guys, > It doesn't > happen all the time, and when I run simple tests I don't see the > error. I should clarify this part a bit: *) I have dozens of .t files that exercise this set of classes, and I've never seen this error there. Devel::Cover tells me I have 100% coverage on most of the classe

Can't locate 0.pm?

2010-05-24 Thread Buddy Burden
Guys, We're seeing a weird error from Class::MOP::load_class. It doesn't happen all the time, and when I run simple tests I don't see the error. Hopefully someone can see something I'm missing in this stack trace: Couldn't load class (Company::CompanyBusinessModel) because: Can't locate 0.pm in

Re: "Bundling" constructor validation errors

2010-04-05 Thread Buddy Burden
Jesse, > You probably want > http://search.cpan.org/dist/MooseX-Constructor-AllErrors/ That looks perfect! Thanx for the tip (and the super quick response time). I will pass this on to my co-worker. -- Buddy

"Bundling" constructor validation errors

2010-04-05 Thread Buddy Burden
Moosites, This is a request from a co-worker; I'll see if I can explain it well. Let's say I have a simple Moose class: use Company::Moose; # this module gets me MooseX::Declare, and also declares all my class types, like the one I'm using below class Foo { has 'bar' => ( is => 'ro', isa =

Currying an attribute

2010-01-28 Thread Buddy Burden
Guys, Not sure this is possible with the currying syntax, but imagine something similar to the following: use MooseX::Declare; class Property { method get_model () { return Model->new; } } class Model { method foo (Property :$property) {} } class PropertyModel { has 'property' => (

Re: Can't put comments in class declarations?

2009-12-23 Thread Buddy Burden
Nick, > It is how the parsing of the class declaration works. We use a mixture > of the facilities provided by Devel::Declare and also PPI (for > signatures) to make the magic happen. Could it be fixed? Probably. This > has to do with the class keyword and option parsing (with, extends, > etc). >

Can't put comments in class declarations?

2009-12-23 Thread Buddy Burden
Guys, This may be a known bug with MooseX::Declare, but I didn't see any mention of it in my cursory web search, so I thought I would ask about it here. This code: use MooseX::Declare; class Foo { } class Bar extends Foo { } compiles fine. But this code: