Skip Menu |

This queue is for tickets about the MooX-ClassAttribute CPAN distribution.

Report information
The Basics
Id: 121641
Status: rejected
Priority: 0/
Queue: MooX-ClassAttribute

People
Owner: Nobody in particular
Requestors: valkoles [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: constructor ignores value
Date: Fri, 12 May 2017 11:10:33 -0700
To: bug-MooX-ClassAttribute [...] rt.cpan.org
From: val <valkoles [...] gmail.com>
#!/usr/bin/env perl use strict; use warnings; { package Foo; use Moo; use MooX::ClassAttribute; class_has foo => is => 'rw', default => 1, ; } my $one = Foo -> new( foo => 2 ); print $one -> foo, "\n"; # expect 2 here, but get 1 $one -> foo( 3 ); print $one -> foo, "\n"; # expect 3 here and get it
On 2017-05-12T19:11:03+01:00, valkoles@gmail.com wrote: Show quoted text
> my $one = Foo -> new( foo => 2 ); > print $one -> foo, "\n"; # expect 2 here, but get 1
Stop expecting that. The documentation doesn't say you can pass class attribute values to a constructor, and I can't see why you'd want to. I'm not going to add support for this. Show quoted text
> $one -> foo( 3 ); > print $one -> foo, "\n"; # expect 3 here and get it
This is also undocumented, but works. No guarantees it will work in future versions. The supported way of setting and getting values is: Foo->foo( 4 ); print Foo->foo, "\n"; # expect 4 here and get it