Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

moose::object(3pm) [debian man page]

Moose::Object(3pm)					User Contributed Perl Documentation					Moose::Object(3pm)

NAME
Moose::Object - The base object for Moose VERSION
version 2.0603 DESCRIPTION
This class is the default base class for all Moose-using classes. When you "use Moose" in this class, your class will inherit from this class. It provides a default constructor and destructor, which run all of the "BUILD" and "DEMOLISH" methods in the inheritance hierarchy, respectively. You don't actually need to inherit from this in order to use Moose, but it makes it easier to take advantage of all of Moose's features. METHODS
Moose::Object->new(%params|$params) This method calls "$class->BUILDARGS(@_)", and then creates a new instance of the appropriate class. Once the instance is created, it calls "$instance->BUILD($params)" for each "BUILD" method in the inheritance hierarchy. Moose::Object->BUILDARGS(%params|$params) The default implementation of this method accepts a hash or hash reference of named parameters. If it receives a single argument that isn't a hash reference it throws an error. You can override this method in your class to handle other types of options passed to the constructor. This method should always return a hash reference of named options. $object->does($role_name) This returns true if the object does the given role. $object->DOES($class_or_role_name) This is a a Moose role-aware implementation of "DOES" in UNIVERSAL. This is effectively the same as writing: $object->does($name) || $object->isa($name) This method will work with Perl 5.8, which did not implement "UNIVERSAL::DOES". $object->dump($maxdepth) This is a handy utility for "Data::Dumper"ing an object. By default, the maximum depth is 1, to avoid making a mess. $object->DESTROY A default destructor is provided, which calls "$instance->DEMOLISH($in_global_destruction)" for each "DEMOLISH" method in the inheritance hierarchy. BUGS
See "BUGS" in Moose for details on reporting bugs. AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for details. COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Moose::Object(3pm)

Check Out this Related Man Page

Moose::Cookbook::Extending::Debugging_BaseClassRole(3pm)User Contributed Perl DocumentatioMoose::Cookbook::Extending::Debugging_BaseClassRole(3pm)

NAME
Moose::Cookbook::Extending::Debugging_BaseClassRole - Providing a role for the base object class VERSION
version 2.0603 SYNOPSIS
package MooseX::Debugging; use Moose::Exporter; Moose::Exporter->setup_import_methods( base_class_roles => ['MooseX::Debugging::Role::Object'], ); package MooseX::Debugging::Role::Object; use Moose::Role; sub BUILD {} after BUILD => sub { my $self = shift; warn "Made a new " . ( ref $self ) . " object "; }; DESCRIPTION
In this example, we provide a role for the base object class that adds some simple debugging output. Every time an object is created, it spits out a warning saying what type of object it was. Obviously, a real debugging role would do something more interesting, but this recipe is all about how we apply that role. In this case, with the combination of Moose::Exporter and Moose::Util::MetaRole, we ensure that when a module does "use MooseX::Debugging", it automatically gets the debugging role applied to its base object class. There are a few pieces of code worth looking at more closely. Moose::Exporter->setup_import_methods( base_class_roles => ['MooseX::Debugging::Role::Object'], ); This creates an "import" method in the "MooseX::Debugging" package. Since we are not actually exporting anything, we do not pass "setup_import_methods" any parameters related to exports, but we need to have an "import" method to ensure that our "init_meta" method is called. The "init_meta" is created by "setup_import_methods" for us, since we passed the "base_class_roles" parameter. The generated "init_meta" will in turn call Moose::Util::MetaRole::apply_base_class_roles. sub BUILD {} after BUILD => sub { ... }; Due to the way role composition currently works, if the class that a role is composed into contains a "BUILD" method, then that will override the "BUILD" method in any roles it composes, which is typically not what you want. Using a method modifier on "BUILD" avoids this issue, since method modifiers compose together rather than being overridden. Method modifiers require that a method exists in order to wrap, however, so we also provide a stub method to wrap if no "BUILD" method exists in the class. AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for details. COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Moose::Cookbook::Extending::Debugging_BaseClassRole(3pm)
Man Page