Skip Menu |

This queue is for tickets about the Class-MethodMaker CPAN distribution.

Report information
The Basics
Id: 80199
Status: rejected
Priority: 0/
Queue: Class-MethodMaker

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

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



Subject: RFE: Need methods to identify the datatype of the attributes declared
We are heavily using Class::MethodMaker to declare the attributes of the class. Eg: package my_package; use Class::MethodMaker [ scalar => 'xyz', scalar => [ { '-default_ctor' => sub { my $self = $_[0]; return $self->invoke_method_abc(); } }, 'abc' ] ]; sub foo { # 'abc' is a mandatory option. Reads _attributes() to determine the list of mandatory options } sub foo1 { # 'abc' is a mandatory option. Reads _attributes() to determine the list of mandatory options } sub invoke_method_abc { ... } sub _attributes { return ['xyz', 'abc']; } It's very useful to provide methods which return back the datatype of the attributes. Eg: my $type = my_package->get_datatype('abc') # Returns 'scalar' There is a base class for the above described package which obtains the attribute names of each of its subclasses by calling _attributes() and it would like to know the datatype for the attributes to perform some other action. Currently it does $value = $pkg_name->$attribute_name(); and it inspects $value. If it is undef, then the attribute is treated as a scalar whereas if it is an empty array ref, then the attribute is considered as an array. This doesn't work well when the attribute is associated with a 'default_ctor' in which case just to find the datatype, the attribute value is unnecessarily populated. So new methods which return the datatype of the attribute would be desired.
Hello Isshwarya, On Mon Oct 15 13:12:30 2012, Isshwarya wrote: Show quoted text
> So new methods which return the datatype of the attribute would be > desired.
Class::MethodMaker is quite in maintenance mode. AFAIK the original author is overly busy and I am just co-maintaining it (without knowing the internals). However, I would happily apply patches and make a new release if you can provide them (ideally with tests). Kind regards, Steffen -- Steffen Schwigon <ss5@renormalist.net> Dresden Perl Mongers <http://dresden-pm.org/>
Class::MethodMaker is in maintenance mode. At least me and the original author can't add new features, I'm very sorry. However, there are many other modern and fast OO toolchains available, please give them a try. Kind regards, Steffen -- Steffen Schwigon <ss5@renormalist.net> Dresden Perl Mongers <http://dresden-pm.org/>