Tie-ToObject-0.03/0000755000076500007650000000000010743520707016573 5ustar nothingmuchnothingmuch00000000000000Tie-ToObject-0.03/lib/0000755000076500007650000000000010743520704017336 5ustar nothingmuchnothingmuch00000000000000Tie-ToObject-0.03/lib/Tie/0000755000076500007650000000000010743520704020057 5ustar nothingmuchnothingmuch00000000000000Tie-ToObject-0.03/lib/Tie/ToObject.pm0000644000076500007650000000334310743520657022140 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl package Tie::ToObject; use strict; #use warnings; use vars qw($VERSION $AUTOLOAD); use Carp qw(croak); use Scalar::Util qw(blessed); $VERSION = "0.03"; sub AUTOLOAD { my ( $self, $tied ) = @_; my ( $method ) = ( $AUTOLOAD =~ /([^:]+)$/ ); if ( $method =~ /^TIE/ ) { if ( blessed($tied) ) { return $tied; } else { croak "You must supply an object as the argument to tie()"; } } else { croak "Unsupported method for $method, this module is only for tying to existing objects"; } } __PACKAGE__ __END__ =pod =head1 NAME Tie::ToObject - Tie to an existing object. =head1 SYNOPSIS use Tie::ToObject; my $stolen = tied(%something); tie %something_else, 'Tie::ToObject', $stolen; =head1 DESCRIPTION While L allows tying to an arbitrary object, the class in question must support this in it's implementation of C, C or whatever. This class provides a very tie constructor that simply returns the object it was given as it's first argument. This way side effects of calling C<< $object->TIEHASH >> are avoided. This is used in L in order to tie a variable to an already existing object. This is also useful for cloning, when you want to clone the internal state object instead of going through the tie interface for that variable. =head1 VERSION CONTROL This module is maintained using Darcs. You can get the latest version from L, and use C to commit changes. =head1 AUTHOR Yuval Kogman Enothingmuch@woobling.orgE =head1 COPYRIGHT Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Tie-ToObject-0.03/Makefile.PL0000644000076500007650000000054210742714572020552 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl -w use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Tie::ToObject', VERSION_FROM => 'lib/Tie/ToObject.pm', INSTALLDIRS => 'site', SIGN => 1, PL_FILES => { }, PREREQ_PM => { 'Tie::RefHash' => 0, # core, used in test 'Test::use::ok' => 0, 'Test::More' => 0, 'Scalar::Util' => 0, }, ); Tie-ToObject-0.03/MANIFEST0000644000076500007650000000036610743520705017727 0ustar nothingmuchnothingmuch00000000000000lib/Tie/ToObject.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP t/tie.t META.yml Module meta-data (added by MakeMaker) SIGNATURE Public-key signature (added by MakeMaker) Tie-ToObject-0.03/MANIFEST.SKIP0000644000076500007650000000103410741201201020446 0ustar nothingmuchnothingmuch00000000000000# Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \b_darcs\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b ### DEFAULT MANIFEST.SKIP ENDS HERE #### \.DS_Store$ \.sw.$ \.tar\.gz$ ^(\w+-)*(\w+)-\d\.\d+$ Tie-ToObject-0.03/META.yml0000644000076500007650000000074510743520704020047 0ustar nothingmuchnothingmuch00000000000000--- #YAML:1.0 name: Tie-ToObject version: 0.03 abstract: ~ license: ~ author: ~ generated_by: ExtUtils::MakeMaker version 6.42 distribution_type: module requires: Scalar::Util: 0 Test::More: 0 Test::use::ok: 0 Tie::RefHash: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Tie-ToObject-0.03/SIGNATURE0000644000076500007650000000205410743520707020060 0ustar nothingmuchnothingmuch00000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.55. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 fb2fc606ec8ec47a725c0224429647883bc36560 MANIFEST SHA1 ddb918d4e02cc06f4b9fe77adeca65403f8fdd56 MANIFEST.SKIP SHA1 b11bf61883c59b77ca02c9e18a2351b10e8f0471 META.yml SHA1 5a18083d49df16d04410f8619e8d5a9c8e1f14fd Makefile.PL SHA1 884c8c13e56b56f5f12c63d4c56680411f60c579 lib/Tie/ToObject.pm SHA1 d0253da0e8838eec69ab366f7e4c59e2d12fb97d t/tie.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFHjqHFVCwRwOvSdBgRAqW4AKC3aHaNf6hOMCvbtNXrJPb0NhsdjQCfTbhK dKHJ9bwz17NqxUEO7RmBvR0= =5SpD -----END PGP SIGNATURE----- Tie-ToObject-0.03/t/0000755000076500007650000000000010743520704017033 5ustar nothingmuchnothingmuch00000000000000Tie-ToObject-0.03/t/tie.t0000644000076500007650000000146410742714632020012 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl use strict; #use warnings; use Test::More tests => 10; use Tie::RefHash; tie my %hash, 'Tie::RefHash'; $hash{ [ 1, 2, 3 ] } = "an array"; $hash{foo} = "a stringy"; use ok 'Tie::ToObject'; tie my %new_hash, 'Tie::ToObject', tied %hash; is( tied(%new_hash), tied(%hash), "tied is the same" ); is_deeply( \%new_hash, \%hash, "is_deeply" ); is( Tie::ToObject->TIEHASH(tied %hash), tied(%hash), "tie is just the identity function" ); eval { tie my %other_hash, 'Tie::ToObject' }; my $e = $@; ok($e, "error" ); like( $e, qr/object.*tie/i, "right error" ); eval { tie my %other_hash, 'Tie::ToObject', { } }; $e = $@; ok($e, "error" ); like( $e, qr/object.*tie/i, "right error" ); eval { Tie::ToObject->blah(tied(%hash)) }; $e = $@; ok($e, "error" ); like( $e, qr/method.*blah/i, "right error" );