Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 32.284.858 Times

Class::Observable 1.04

  Date Added: January 13, 2010  |  Visits: 674

Class::Observable

Report Broken Link
Printer Friendly Version


Product Homepage
Download (79 downloads)

Class::Observable is a Perl module that allows other classes and objects to respond to events in yours. SYNOPSIS # Define an observable class package My::Object; use base qw( Class::Observable ); # Tell all classes/objects observing this object that a state-change # has occurred sub create { my ( $self ) = @_; eval { $self->_perform_create() }; if ( $@ ) { My::Exception->throw( "Error saving: $@" ); } $self->notify_observers(); } # Same thing, except make the type of change explicit and pass # arguments. sub edit { my ( $self ) = @_; my %old_values = $self->extract_values; eval { $self->_perform_edit() }; if ( $@ ) { My::Exception->throw( "Error saving: $@" ); } $self->notify_observers( edit, old_values => %old_values ); } # Define an observer package My::Observer; sub update { my ( $class, $object, $action ) = @_; unless ( $action ) { warn "Cannot operation on [", $object->id, "] without action"; return; } $class->_on_save( $object ) if ( $action eq save ); $class->_on_update( $object ) if ( $action eq update ); } # Register the observer class with all instances of the observable # class My::Object->add_observer( My::Observer ); # Register the observer class with a single instance of the # observable class my $object = My::Object->new( foo ); $object->add_observer( My::Observer ); # Register an observer object the same way my $observer = My::Observer->new( bar ); My::Object->add_observer( $observer ); my $object = My::Object->new( foo ); $object->add_observer( $observer ); # Register an observer using a subroutine sub catch_observation { ... } My::Object->add_observer( &catch_observation ); my $object = My::Object->new( foo ); $object->add_observer( &catch_observation ); # Define the observable class as a parent and allow the observers to # be used by the child package My::Parent; use strict; use base qw( Class::Observable ); sub prepare_for_bed { my ( $self ) = @_; $self->notify_observers( prepare_for_bed ); } sub brush_teeth { my ( $self ) = @_; $self->_brush_teeth( time => 45 ); $self->_floss_teeth( time => 30 ); $self->_gargle( time => 30 ); } sub wash_face { ... } package My::Child; use strict; use base qw( My::Parent ); sub brush_teeth { my ( $self ) = @_; $self->_wet_toothbrush(); } sub wash_face { return } # Create a class-based observer package My::ParentRules; sub update { my ( $item, $action ) = @_; if ( $action eq prepare_for_bed ) { $item->brush_teeth; $item->wash_face; } } My::Parent->add_observer( __PACKAGE__ ); $parent->prepare_for_bed # brush, floss, gargle, and wash face $child->prepare_for_bed # pretend to brush, pretend to wash face.

Requirements: No special requirements
Platforms: Linux
Keyword: Action Brush Class Classobservable Libraries Object Observer Perl Module Programming Sub
Users rating: 0/10

License: Freeware Size: 10.24 KB
CLASS::OBSERVABLE RELATED
Libraries  -  Class::Std::Storable 0.0.1
Class::Std::Storable is a Perl module to support for creating serializable "inside-out" classes. SYNOPSIS In general, use this class exactly as you would Class::Std. package Ice::Cream; use Class::Std::Storable; { my %name_of :ATTR( :get...
8.19 KB  
Libraries  -  Class::Meta::Declare 0.04
Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express. SYNOPSIS This was a first attempt at making a saner interface for Class::Meta. It is nicer, but Class::Meta::Express is nicer still. Go use that one. package...
15.36 KB  
Libraries  -  Class::Std::Utils 0.0.2
Class::Std::Utils is a Perl module for utility subroutines for building "inside-out" objects. SYNOPSIS use Class::Std::Utils; # Constructor for anonymous scalars... my $new_object = bless anon_scalar(), $class; # Convert an object...
5.12 KB  
Libraries  -  Class::DBI::FormBuilder 0.481
Class::DBI::FormBuilder is a Perl module with Class::DBI/CGI::FormBuilder integration. SYNOPSIS package Film; use strict; use warnings; use base Class::DBI; use Class::DBI::FormBuilder; # for indented output: # use...
46.08 KB  
Libraries  -  Class::Meta::Express 0.04
Class::Meta::Express is a Perl module for concise, expressive creation of Class::Meta classes. Synopsis package My::Contact; use Class::Meta::Express; class { meta contact => ( default_type => string ); has name; has contact => (...
9.22 KB  
Libraries  -  Class::Meta::Type 0.53
Class::Meta::Type is a Perl module for data type validation and accessor building. SYNOPSIS package MyApp::TypeDef; use strict; use Class::Meta::Type; use IO::Socket; my $type = Class::Meta::Type->add( key => io_socket, desc =>...
61.44 KB  
Libraries  -  Class::Declare::Attributes 0.04
Class::Declare::Attributes is a Perl module with Class::Declare method types using Perl attributes. SYNOPSIS package My::Class; use 5.006; use strict; use warnings; use base qw( Class::Declare::Attributes ); # declare the...
21.5 KB  
Libraries  -  Class::Method::hash 2.08
Class::Method::hash is a Perl module that helps you create methods for handling a hash value. SYNOPSIS use Class::MethodMaker [ hash => [qw/ x /] ]; $instance->x; # empty $instance->x(a => 1, b => 2, c => 3); $instance->x_count == 3; #...
89.09 KB  
Libraries  -  DBIx::Class::Manual::Cookbook 0.08001
DBIx::Class::Manual::Cookbook is a Perl module that contains miscellaneous recipes. Paged results When you expect a large number of results, you can ask DBIx::Class for a paged resultset, which will fetch only a small number of records at a...
286.72 KB  
Libraries  -  Class::Adapter::Builder 1.02
Class::Adapter::Builder is a Perl module that can generate Class::Adapter classes. SYNOPSIS package My::Adapter; use strict; use Class::Adapter::Builder ISA => Specific::API, METHODS => [ qw{foo bar baz} ], method => different_method;...
24.58 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 3.15.3
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB