Git Product home page Git Product logo

moosex-traitor's Introduction

Build Status Kwalitee status Coverage Status

NAME

MooseX::Traitor - An alternate way to compose your classes with traits

VERSION

This document describes version 0.006 of MooseX::Traitor - released June 25, 2015 as part of MooseX-Traitor.

SYNOPSIS

# in your class definition...
package MyClass;
use Moose;
use namespace::autoclean;

with 'MooseX::Traitor';

# somewhere else in Gotham...
my $thinger = MyClass->with_traits('Thinger::Trait1')->new(...);

DESCRIPTION

One of the most powerful things about Moose is that with roles and easy "anonymous" class creation we are blessed with a fantastic new way of creating classes, often on the fly, out of other classes and those composable bits of behaviour, roles.

Even better, this application of discrete chunks of behaviours enables people simply using a class to extend and tweak its behaviour in new ways -- possibly ways never contemplated by the authors of the classes being altered.

METHODS

with_traits(, ...)

This method builds an anonymous class from the consuming class and any traits specified.

You may use the full trait specification syntax, e.g.:

MyClass->with_traits('My::Trait' => { -excludes => ... })

Calling this routine with no traits specified will simply return the name of the class. This is not considered an error.

Note that we handle being called directly against a package (e.g. MyClass->with_traits(...)) and against an instance (e.g. $self->with_traits(...)) identically; in each instance the class referenced is subclassed.

ROLES OR TRAITS?

There are many different definitions of what a role is vs a trait, ranging from "hey man, it's all cool" to "CLOS calls them all traits SO TRAITS IS THE ONE TRUE NAME", it seems that most people tend to think of them this way:

Roles are traits that a class knowingly consumes (e.g. via with()).

Traits are roles that are applied without the class' consent (e.g. anonymous subclass composition or $trait_meta->apply('ClassThinger')).

Or maybe that's just what this author is imposing on everyone else. Either way, that's what we'll be using here if the definition ever becomes important.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/RsrchBoy/moosex-traitor/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Chris Weyl [email protected]

I'm a material boy in a material world

Please note I do not expect to be gittip'ed or flattr'ed for this work, rather it is simply a very pleasant surprise. I largely create and release works like this because I need them or I find it enjoyable; however, don't let that stop you if you feel like it ;)

Flattr, Gratipay, or indulge my Amazon Wishlist... If and *only* if you so desire.

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Chris Weyl.

This is free software, licensed under:

The GNU Lesser General Public License, Version 2.1, February 1999

moosex-traitor's People

Contributors

rsrchboy avatar

Watchers

 avatar  avatar

moosex-traitor's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.