<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Method::Assert - Ensure instance and class methods are called properly

VERSION
    version 0.0.1

SYNOPSIS
        package MyClass;

        use Method::Assert;
        use Carp qw(confess);

        sub new {
            my ($class, @args) = &amp;class_method;
            my $self = {};
            bless $self, $class;
            $self-&gt;_init(@args);
            return $self;
        }

        sub _init {
            my ($self, @args) = @_; # Perl Critic prefers it this way
            &amp;instance_method;       # still works
            ...
        }

        sub get_output_filename {
            &amp;instance_method;
            return shift-&gt;{'output_filename'};
        }

        sub set_output_filename {
            my $self = &amp;instance_method;
            confess("No parameter specified") unless @_;
            confess("File already exists") if -e $_[0];
            $self-&gt;{'output_filename'} = $_[0];
            return $self;
        }

DESCRIPTION
    This module will export the two functions named below into the namespace
    of the package using it. These two functions are useful to do typical
    checks at the start of functions that are supposed to be either class or
    instance methods.

    Always remember to call these functions as &amp;class_method and
    &amp;instance_method, or else they will not work properly!

    If you call them as "class_method()" or "instance_method()" a new
    version of @_ will be initialized, and manipulation of @_ will not work
    properly.

FUNCTIONS
  class_method
    Use this function to check that the sub is called as a class method. If
    the sub is called as a function, or as an instance method this function
    will die.

    If called in scalar context, will shift of the first argument of the @_
    array and return that value. If called in list or void context it will
    not change @_.

  instance_method
    Use this function to check that the sub is called as an instance method.
    If the sub is called as a function, or as a class method this function
    will die.

    If called in scalar context, will shift of the first argument of the @_
    array and return that value. If called in list or void context it will
    not change @_.

CAVEATS
    The two functions can NOT be called by the fully qualified method name
    because they are generated as closures in the calling package's
    namespace during import(). Writing "use Method::Assert ()" will cause
    import() not to be executed, which doesn't not make sense. See the
    section on *import* in "perldoc -f use" for more information.

SEMANTIC VERSIONING
    This module uses semantic versioning concepts from &lt;http://semver.org/&gt;.

SEE ALSO
    *   Method::Signatures

    *   Devel::Declare

    *   MooseX::Method::Signatures

    *   MooseX::Declare

SUPPORT
    You can find documentation for this module with the perldoc command.

      perldoc Method::Assert

  Websites
    *   Search CPAN

        &lt;http://search.cpan.org/dist/Method-Assert&gt;

    *   AnnoCPAN: Annotated CPAN documentation

        &lt;http://annocpan.org/dist/Method-Assert&gt;

    *   CPAN Ratings

        &lt;http://cpanratings.perl.org/d/Method-Assert&gt;

    *   CPAN Forum

        &lt;http://cpanforum.com/dist/Method-Assert&gt;

    *   RT: CPAN's Bug Tracker

        &lt;http://rt.cpan.org/NoAuth/Bugs.html?Dist=Method-Assert&gt;

    *   CPANTS Kwalitee

        &lt;http://cpants.perl.org/dist/overview/Method-Assert&gt;

    *   CPAN Testers Results

        &lt;http://cpantesters.org/distro/M/Method-Assert.html&gt;

    *   CPAN Testers Matrix

        &lt;http://matrix.cpantesters.org/?dist=Method-Assert&gt;

    *   Source Code Repository

        The code is open to the world, and available for you to hack on.
        Please feel free to browse it and play with it, or whatever. If you
        want to contribute patches, please send me a diff or prod me to pull
        from your repository :)

        &lt;git://github.com/robinsmidsrod/Method-Assert.git&gt;

  Bugs
    Please report any bugs or feature requests to "bug-method-assert at
    rt.cpan.org", or through the web interface at
    &lt;http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Method-Assert&gt;. I will
    be notified, and then you'll automatically be notified of progress on
    your bug as I make changes.

AUTHOR
      Robin SmidsrĂ¸d &lt;robin@smidsrod.no&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2010 by Robin SmidsrĂ¸d.

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

</pre></body></html>