Reflexive::Role::Collective - Provides a composable behavior for containers watching contained events
version 1.113340
Reflexive::Role::Collective provides are more comprehensive and extensible way to define collections that act upon events emitted from contained objects.
While Reflex::Collection merely watches for the 'stopped' event and removes it from the collection, a more sophisticated Collection can be built using this role that will do much more such as proper socket management, re-emit events, etc.
default: objects
store contains the name of the attribute that holds the actual collection of objects.
default: add_object
method_add_object is the name of the method that adds an object to the collection.
default: delete_object
method_del_object is the name of the method that deletes objects from the collection.
default: count_objects
method_count_objects is the name of the method that returns the current count of objects within the collection.
default: clear_objects
method_clear_objects is the name of the method that clears the collection of any objects.
default: remember
method_remember is the name of the method that stores the collectible and sets up watching the events that collectible emits.
default: forget
method_forget is the name of the method that removes the collectible and ignores any events that the collectible emits.
default: Any
stored_constraint stores a Moose::Meta::TypeConstaint object to be used to constraint collectibles before they are stored into the collection.
isa: ArrayRef[Tuple[Str,Str|Tuple[Str,Str]]],
watched_events contains an arrayref of tuples that indicate the event to watch and the callback method name to call when that event occurs. If the callback method name is also a tuple, a method will be setup with the name of the first element of the tuple and it will emit the event in the second element
# example [ some_event => [ 'some_method_that_emits' => 'this_event' ] ]
Internally, the embedded tuple is passed unmodified to "method_emit" in Reflex::Role. This allows for easy setup of watched events that merely re-emit.
This role requires the method ignore from Reflex::Base
This role requires the method watch from Reflex::Base
This role requires the method named in method_clear_objects
This role requires the method named in method_count_objects
This role requires the method named in method_add_object
This role requires the method named in method_del_object
remember takes an object constrained by "store_constraint". It will then watch all of the events listed in "watched_events" and store the object into the collection
forget takes an object constrained by "store_constraint". It will then ignore all of the events the collection was watching and the object will be removed from the collection.
Nicholas R. Perez <nperez@cpan.org>
This software is copyright (c) 2011 by Nicholas R. Perez <nperez@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Reflexive::Role::Collective, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflexive::Role::Collective
CPAN shell
perl -MCPAN -e shell install Reflexive::Role::Collective
For more information on module installation, please visit the detailed CPAN module installation guide.