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
Data::Object::State(3) User Contributed Perl Documentation Data::Object::State(3)

Data::Object::State

Singleton Builder for Perl 5

  package Example;

  use Data::Object::State;

  has data => (
    is => 'ro'
  );

  package main;

  my $example = Example->new;

This package provides an abstract base class for creating singleton classes. This package is derived from Moo and makes consumers Moo classes (with all that that entails). This package also injects a "BUILD" method which is responsible for hooking into the build process and returning the appropriate state.

This package implements the following methods:

  renew() : Object

The new method sets the internal state and returns a new class instance. Subsequent calls to "new" will return the same instance as was previously returned.

new example #1
  package Example::New;

  use Data::Object::State;

  has data => (
    is => 'ro'
  );

  my $example1 = Example::New->new(data => 'a');
  my $example2 = Example::New->new(data => 'b');

  [$example1, $example2]
    

  renew() : Object

The renew method resets the internal state and returns a new class instance. Each call to "renew" will discard the previous state, then reconstruct and stash the new state as requested.

renew example #1
  package Example::Renew;

  use Data::Object::State;

  has data => (
    is => 'ro'
  );

  my $example1 = Example::Renew->new(data => 'a');
  my $example2 = $example1->renew(data => 'b');
  my $example3 = Example::Renew->new(data => 'c');

  [$example1, $example2, $example3]
    

Al Newkirk, "awncorp@cpan.org"

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file" <https://github.com/iamalnewkirk/data-object-state/blob/master/LICENSE>.

Wiki <https://github.com/iamalnewkirk/data-object-state/wiki>

Project <https://github.com/iamalnewkirk/data-object-state>

Initiatives <https://github.com/iamalnewkirk/data-object-state/projects>

Milestones <https://github.com/iamalnewkirk/data-object-state/milestones>

Contributing <https://github.com/iamalnewkirk/data-object-state/blob/master/CONTRIBUTE.md>

Issues <https://github.com/iamalnewkirk/data-object-state/issues>

2020-03-30 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.