GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MouseX::NativeTraits::Bool(3) User Contributed Perl Documentation MouseX::NativeTraits::Bool(3)

MouseX::NativeTraits::Bool - Helper trait for Bool attributes

  package Room;
  use Mouse;

  has 'is_lit' => (
      traits    => ['Bool'],
      is        => 'rw',
      isa       => 'Bool',
      default   => 0,
      handles   => {
          illuminate  => 'set',
          darken      => 'unset',
          flip_switch => 'toggle',
          is_dark     => 'not',
      },
  );

  my $room = Room->new();
  $room->illuminate;     # same as $room->is_lit(1);
  $room->darken;         # same as $room->is_lit(0);
  $room->flip_switch;    # same as $room->is_lit(not $room->is_lit);
  return $room->is_dark; # same as !$room->is_lit

This provides a simple boolean attribute, which supports most of the basic math operations.

These methods are implemented in MouseX::NativeTraits::MethodProvider::Bool. It is important to note that all those methods do in place modification of the value stored in the attribute.
set
Sets the value to true.
unset
Set the value to false.
toggle
Toggles the value. If it's true, set to false, and vice versa.
not
Equivalent of 'not $value'.

meta
method_provider_class
helper_type

MouseX::NativeTraits.
2012-11-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.