perl - What is the most efficient way to override an attribute in lots of my Moose based sub classes? -
I'm using it to be used to be a subclass and then you type field_name_space
Or overwrite certain attributes like attribute_name_space
.
However, now I have so many forms that extend the HTML :: FormHandler
or its DBIC based version and therefore these super-bound properties have been repeated many times.
I tried to put them in a role but got an error which is not supported in roles + attr
notation is sufficiently reasonable.
What is the best way to destroy this repetition? I thought maybe that is a subclass but then I have to do this twice for HTML :: FormHandler
and HTML :: FormHandler :: Model :: DBIC
, plus I believe That's the general thought that instead of subclassing is better received with better roles.
Update: I thought it would be a good idea to give an example. This is what I am currently doing - and it includes code repeat as you can see that a form uses a different parental class, so I did not create an original class to put the attribute override in. can. I have to make two- and also add redundancy too
package MyApp :: Form :: Foo; # This form does not interfere with DBIC 'HTML :: form handler'; '+ Html_prefix' = & gt; (Default => 1); Is' + fields_trats = = & gt; (Default = & gt; sub [[MyApp :: Form :: Trait :: Field ']}); '+ Field_name_space' = & gt; (Default = & gt; 'MyApp :: Form :: Field'); '+ Widget_name_space' = & gt; (Default = & gt; sub [[MyApp :: Form :: Widget ']}); '+ Widget_wrapper' = & gt; (Default = & gt; 'none'); ... package MyApp :: Form :: Bar; # This form uses the DBIC object 'HTML :: FormHalller :: Model :: DBIC'; '+ Html_prefix' = & gt; (Default => 1); Is' + fields_trats = = & gt; (Default = & gt; sub [[MyApp :: Form :: Trait :: Field ']}); '+ Field_name_space' = & gt; (Default = & gt; 'MyApp :: Form :: Field'); '+ Widget_name_space' = & gt; (Default = & gt; sub [[MyApp :: Form :: Widget ']}); '+ Widget_wrapper' = & gt; (Default = & gt; 'none'); ... package MyApp :: Form :: Baz; # This form also uses the DBIC object 'HTML :: FormHalller :: Model :: DBIC'; '+ Html_prefix' = & gt; (Default => 1); Is' + fields_trats = = & gt; (Default = & gt; sub [[MyApp :: Form :: Trait :: Field ']}); '+ Field_name_space' = & gt; (Default = & gt; 'MyApp :: Form :: Field'); '+ Widget_name_space' = & gt; (Default = & gt; sub [[MyApp :: Form :: Widget ']}); '+ Widget_wrapper' = & gt; (Default = & gt; 'none');
HTML :: FormHandler :: DBIC
In order to help in this situation, in a mousal characteristic, you can inherit from your base class, and in your form using the DBIC model, you get the formhanger :: travelfor :: model :: dbic With ' ;
Comments
Post a Comment