unmocked - use real libraries from within mocked libraries


mocked documentation Contained in the mocked distribution.

Index


Code Index:

NAME

Top

unmocked - use real libraries from within mocked libraries

SYNOPSIS

Top

  # Your mocked module needs to use a real library
  package Fake::Fun;
  use unmocked 'URI';

DESCRIPTION

Top

When mocking modules using 'mocked', you are certain that no extra "real" libraries are being loaded. But sometimes you don't want to use real libraries from within your mocked library. This module allows you to load real libraries using your previous include paths.

FUNCTIONS

Top

import

With a package name, this function will ensure that the module you specify is loaded from the regular @INC path (that mocked.pm has removed).

AUTHOR

Top

Luke Closs, <cpan at 5thplane.com>

LICENSE

Top

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


mocked documentation Contained in the mocked distribution.
package unmocked;
use strict;
use warnings;
use mocked;

our $VERSION = '0.01';

sub import {
    my $class = shift;
    my $module = shift;
    return unless $module;
 
    {
      local @INC = @$mocked::real_inc_paths;
      eval "require $module";
    }
    die $@ if $@;

    my $import = $module->can('import');
    @_ = ($module, @_);
    goto &$import if $import;
}

1;