Re: Enforcing constraints when changing an instances property values ?

2010-06-16 Thread Oliver Charles
I should also mention if you want to be able to change the Type internally, but not expose it as part of the public API, you could use a private writer method (prefixed with _). See the "reader" and "writer" properties of attributes. -- Oliver Charles / aCiD2

Re: Enforcing constraints when changing an instances property values ?

2010-06-16 Thread Oliver Charles
On Tue, Jun 15, 2010 at 7:17 PM, Stephen Prytherch wrote: > Hello, > I have small problem. I define a class 'Node' with 2 enums Action and State > and when creating an instance it enforces constraints correctly. However > once I’ve created an instance it doesn’t seem to enforce constraints. > > ..

Re: Enforcing constraints when changing an instances property values ?

2010-06-16 Thread Stevan Little
On Jun 15, 2010, at 2:17 PM, Stephen Prytherch wrote: package main; my $btn = HtmlElement->new( Name => 'myButton', Type => 'Button'); $btn->{Type}='An Illegal Value'; You need to call the ->Type method, if you directly access the underlying HASHref then you are bypassing Moose. - Steva

Enforcing constraints when changing an instances property values ?

2010-06-16 Thread Stephen Prytherch
Hello, I have small problem. I define a class 'Node' with 2 enums Action and State and when creating an instance it enforces constraints correctly. However once I’ve created an instance it doesn’t seem to enforce constraints. At the end of the following code if I dump $btn I see: DB<5> x $btn