-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Test-Builder1.5' into issue/242
- Loading branch information
Showing
27 changed files
with
285 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package TB2::HasObjectID; | ||
|
||
require TB2::Mouse; | ||
use TB2::Mouse::Role; | ||
|
||
our $VERSION = '1.005000_001'; | ||
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||
|
||
|
||
=head1 NAME | ||
TB2::HasObjectID - a unique id in the current process | ||
=head1 SYNOPSIS | ||
package My::Thing; | ||
use TB2::Mouse; | ||
with "TB2::HasObjectID"; | ||
my $thing = My::Thing->new; | ||
my $id = $thing->object_id; | ||
=head1 DESCRIPTION | ||
Provides a method for generating unique ids for many TB2 objects. | ||
Useful if, for example, an EventHandler posts its own events and | ||
doesn't want to process them twice. | ||
=head3 object_id | ||
my $id = $thing->object_id; | ||
Returns an identifier for this object unique to the running process. | ||
The identifier is fairly simple and easily predictable. | ||
=cut | ||
|
||
my $Counter = int rand(1_000_000); | ||
has object_id => | ||
is => 'ro', | ||
isa => 'Str', | ||
lazy => 1, | ||
default => sub { | ||
my $self = shift; | ||
|
||
# Include the class in case somebody else decides to use | ||
# just an integer. | ||
return ref($self) . '-' . $Counter++; | ||
} | ||
; | ||
|
||
no TB2::Mouse; | ||
no TB2::Mouse::Role; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.