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


Manual Reference Pages  -  MOUSEX::NATIVETRAITS::COUNTER (3)

.ds Aq ’

NAME

MouseX::NativeTraits::Counter - Helper trait for counter attributes

CONTENTS

SYNOPSIS



  package MyHomePage;
  use Mouse;

  has counter => (
      traits    => [Counter],
      is        => ro,
      isa       => Num,
      default   => 0,
      handles   => {
          inc_counter   => inc,
          dec_counter   => dec,
          reset_counter => reset,
      },
  );

  my $page = MyHomePage->new();
  $page->inc_counter; # same as $page->counter( $page->counter + 1 );
  $page->dec_counter; # same as $page->counter( $page->counter - 1 );



DESCRIPTION

This module provides a simple counter attribute, which can be incremented and decremented.

If your attribute definition does not include any of is, isa, default or handles but does use the Counter trait, then this module applies defaults as in the SYNOPSIS above. This allows for a very basic counter definition:



  has foo => (traits => [Counter]);
  $obj->inc_foo;



PROVIDED METHODS

These methods are implemented in MouseX::NativeTraits::MethodProvider::Counter. It is important to note that all those methods do in place modification of the value stored in the attribute.
<B>set($value)B> Set the counter to the specified value.
<B>incB> Increments the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount.
<B>decB> Decrements the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount.
<B>resetB> Resets the value stored in this slot to it’s default value.

METHODS

<B>metaB>
<B>method_provider_classB>
<B>helper_typeB>

SEE ALSO

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


perl v5.20.3 MOUSEX::NATIVETRAITS::COUNTER (3) 2012-11-26

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