Alt-IO-All-new
view release on metacpan or search on metacpan
* The behavior it provides depends on the state of the scope
* The behavior it provides also depends on the arguments passed to
"use IO::All"
* "io" returns an IO::All object
* The IO::All object has no I/O capabilities
* Further method calls invoke a context, causing the IO::All
object to rebless itself it something useful like IO::All::File.
* Certain methods force a rebless
* `file(...), dir(...), socket(...), etc
* These methods are more or less hard-coded currently
* Options to "use IO::All" that begin with a "-", cause a method to be
called on each new IO::All object.
* use IO::All -strict, -encoding => 'big5'; # causes:
}
So you need to load any extensions that you want to use, within the
scope that you want them in. Exceptions are IO::All::File and
IO::All::Dir, which are automatically loaded, unless you say:
use IO::All -none;
Plugins can register 3 things:
* Register a method (or methods) that will force a rebless in that
class.
* Register a regexp (or function) that will cause a rebless when the
input to io(...) matches.
* Register overloads that the plugin responds to.
These things are register according to the scope of the IO::All, so that
the "io" function will do the right things.
Transition to the new API
It needs to be determined if the changes that need to be made are too
destructive to coexist with the current IO::All. That determination
inc/Pegex/Base.pm view on Meta::CPAN
package Pegex::Base;
# use Mo qw'build default builder xxx import nonlazy required';
# The following line of code was produced from the previous line by
# Mo::Inline version 0.38
no warnings;my$M=__PACKAGE__.'::';*{$M.Object::new}=sub{my$c=shift;my$s=bless{@_},$c;my%n=%{$c.'::'.':E'};map{$s->{$_}=$n{$_}->()if!exists$s->{$_}}keys%n;$s};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.'::';shift;eval"no Mo::$_",&{...
our $DumpModule = 'YAML';
1;
inc/TestML/Base.pm view on Meta::CPAN
package TestML::Base;
# use Mo qw'build default builder xxx import';
# The following line of code was produced from the previous line by
# Mo::Inline version 0.38
no warnings;my$M=__PACKAGE__.'::';*{$M.Object::new}=sub{my$c=shift;my$s=bless{@_},$c;my%n=%{$c.::.':E'};map{$s->{$_}=$n{$_}->()if!exists$s->{$_}}keys%n;$s};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.'::';shift;eval"no Mo::$_",&{$M...
our $DumpModule = 'YAML';
1;
lib/Alt/IO/All/new.pod view on Meta::CPAN
=item * The behavior it provides also depends on the arguments passed to C<use IO::All>
=back
=item * C<io> returns an IO::All object
=over
=item * The IO::All object has no I/O capabilities
=item * Further method calls invoke a context, causing the IO::All object to rebless itself it something useful like IO::All::File.
=back
=item * Certain methods force a rebless
=over
=item * `file(...), dir(...), socket(...), etc
=item * These methods are more or less hard-coded currently
=back
=item * Options to C<use IO::All> that begin with a C<->, cause a method to be called on each new IO::All object.
lib/Alt/IO/All/new.pod view on Meta::CPAN
So you need to load any extensions that you want to use, within the scope that
you want them in. Exceptions are IO::All::File and IO::All::Dir, which are
automatically loaded, unless you say:
use IO::All -none;
Plugins can register 3 things:
=over
=item * Register a method (or methods) that will force a rebless in that class.
=item * Register a regexp (or function) that will cause a rebless when the input to io(...) matches.
=item * Register overloads that the plugin responds to.
=back
These things are register according to the scope of the IO::All, so that the
C<io> function will do the right things.
=head1 Transition to the new API
lib/IO/All.pm view on Meta::CPAN
if @_ > 1;
my $location = @_ ? shift(@_) : undef;
$class->new([-location => $location], @$scope_args);
};
}
{
no warnings 'redefine';
sub new {
my $class = shift;
my $self = bless {}, $class;
for (@_) {
my $property = shift(@$_);
$property =~ s/^-//;
$self->$property(@$_);
}
for my $plugin_class (@{$self->plugin_classes}) {
eval "require $plugin_class; 1"
or $self->throw("Can't require $plugin_class: $@");
$self->register_methods($plugin_class);
$self->register_overloads($plugin_class);
if ($plugin_class->can_upgrade($self)) {
$self->rebless($plugin_class);
last;
}
}
return $self;
}
}
# Parse
# use IO::All -foo, -bar => 'x', 'y', -baz => 0;
# Into
lib/IO/All.pm view on Meta::CPAN
my ($self, $plugin_class) = @_;
}
sub AUTOLOAD {
my $self = shift;
(my $method = $IO::All::AUTOLOAD) =~ s/.*:://;
my $plugin_class = $self->methods->{$method}
or $self->throw(
"Can't locate object method '$method' for '$self' object"
);
$self->rebless($plugin_class);
$self->$method(@_);
}
sub rebless {
my ($self, $plugin_class) = @_;
delete $self->{plugin_classes};
bless $self, $plugin_class;
$self->upgrade;
}
sub DESTROY {}
1;
lib/IO/All/Base.pm view on Meta::CPAN
package IO::All::Base;
# use Mo qw'default build import exporter xxx';
# The following line of code was produced from the previous line by
# Mo::Inline version 0.38
no warnings;my$M=__PACKAGE__.'::';*{$M.Object::new}=sub{my$c=shift;my$s=bless{@_},$c;my%n=%{$c.::.':E'};map{$s->{$_}=$n{$_}->()if!exists$s->{$_}}keys%n;$s};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.'::';shift;eval"no Mo::$_",&{$M...
our @EXPORT = qw(chain option);
sub option {
my $package = caller;
my ($field, $default) = @_;
$default ||= 0;
field("_$field", $default);
no strict 'refs';
*{"${package}::$field"} =
( run in 0.457 second using v1.01-cache-2.11-cpan-de7293f3b23 )