Create a subclass that allows accessing and modifying attributes of an object in a codebase.
One of the main functions in dtRdr::Accessor is _create_package. This method creates a package and returns a reference to it. It also pushes the newly-created package into the caller's @ISA. If a package with the same name already exists, dtRdr::Accessor will return a cached value instead of creating a new one.
Another useful function, _mk_alias_get, creates an alias for a getter method that matches its corresponding attribute name. This operation helps you get the attribute value in a more readable and straightforward way.
The module provides three different access levels. You can create a read-only attribute by calling the ro method and passing a list with the attribute names as arguments. You can create read-write attributes with the rw method, which works similarly to the ro method. Lastly, you can create an attribute that is read-only within the class but writable outside it by using the ro_w method.
If you need to create attributes that are accessible from the class level instead of the instance level, use class_ro, class_rw, and class_ro_w. The last method creates a getter and setter for an attribute and hands you a reference to the setter instead of installing it automatically.
Finally, dtRdr::Accessor offers the _mk_class_accessors method to create class-level accessors in bulk. You only need to specify the name of the package, access type (read-only or read-write), and the attributes you want to create.
Overall, dtRdr::Accessor is a reliable Perl module that simplifies the creation of accessor subclasses by providing all the necessary functions and utilities. If you're working on a large project and want to make sure your code is as clean and readable as possible, this library is a valuable asset to add to your toolset.
Version 0.11.2: N/A