Method::Signatures::Simple - Basic method declarations with signatures, without source filters


NAME

Method::Signatures::Simple - Basic method declarations with signatures, without source filters


VERSION

version 1.07


SYNOPSIS

    # -- a basic class -- #
    package User;
    use Method::Signatures::Simple;
    method new ($class: $name, $email) {
        my $user = {
            id    => new_id(42),
            name  => $name,
            email => $email,
        };
        bless $user, $class;
    }
    func new_id ($seed) {
        state $id = $seed;
        $id++;
    }
    method name  { $self->{name};  }
    method email { $self->{email}; }
    1;
    # -- other features -- #
    # attributes
    method foo : lvalue { $self->{foo} }
    # change invocant name
    use Method::Signatures::Simple invocant => '$this';
    method foo ($bar) { $this->bar($bar) }
    method bar ($class: $bar) { $class->baz($bar) }
    # use a different function keyword
    use Method::Signatures::Simple function_keyword => 'fun';
    fun triple ($num) { 3 * $num }
    # use a different method keyword
    use Method::Signatures::Simple method_keyword => 'action';
    action foo { $self->bar }


RATIONALE

This module provides basic method and func keywords with simple signatures. It's intentionally simple, and is supposed to be a stepping stone for its bigger brothers the MooseX::Method::Signatures manpage and the Method::Signatures manpage. It only has a small benefit over regular subs, so if you want more features, look at those modules. But if you're looking for a small amount of syntactic sugar, this might just be enough.


FEATURES


ADVANCED CONFIGURATION

Since this module subclasses the Devel::Declare::MethodInstaller::Simple manpage, you can change the keywords and the default invocant with import arguments. These changes affect the current scope.


AUTHOR

Rhesa Rozendaal, <rhesa at cpan.org>


BUGS

Please report any bugs or feature requests to bug-method-signatures-simple at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


SUPPORT

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

    perldoc Method::Signatures::Simple

You can also look for information at:


ACKNOWLEDGEMENTS


SEE ALSO

the Devel::Declare manpage, the Method::Signatures manpage, the MooseX::Method::Signatures manpage.


COPYRIGHT & LICENSE

Copyright 2011 Rhesa Rozendaal, all rights reserved.

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

 Method::Signatures::Simple - Basic method declarations with signatures, without source filters