NAME
Entities::Plan - A collection of features (possibly scoped and limited) customers can subscribe to.
VERSION
version 0.4
SYNOPSIS
used internally, see L<Entities>
DESCRIPTION
A plan is merely a collection of features. Customer get access to these features by subscribing to a plan. In a paid webapp, for example, you might have plans such as 'Free', 'Small', 'Medium' and 'Large', with feature count increasing from plan to plan. Plans can also inherit from other plans to make things a little easier.
This entity class does
the Abilities::Features Moose role.
NOTE: you are not meant to create plan objects directly, but only through the new_plan()
method in Entities.
METHODS
new( name => 'someplan', [ description => 'Just some plan', features => [], plans => [], created => $dt_obj, modified => $other_dt_obj, parent => $entities_obj, id => 123 ] )
Creates a new instance of this module. Only 'name' is required.
id()
Returns the ID of the plan, if set.
has_id()
Returns a true value if the plan object has an ID attribute.
_set_id( $id )
Sets the ID of the plan object to the provided value. Only to be used internally.
name()
Returns the name of the plan.
description()
Returns the description text of this plan.
set_description( $desc )
Changes the description of the object to the provided value.
features( [\@features] )
In scalar context, returns an array-ref of all feature names this plan directly has. In list context returns an array. If an array-ref of feature names is provided, it replaces the current list.
has_features()
Returns a true value if the plan has been assigned any features.
plans( [\@plans] )
In scalar context, returns an array-ref of plan names this plan inherits from. In list context returns an array. If an array-ref of plan names is provided, it will replace the current list.
has_plans()
Returns a true value if the plan object inherits from any other plan.
created()
Returns a DateTime object in the time the plan object has been created.
modified( [$dt] )
Returns a DateTime object in the last time the object has been modified. If a DateTime object is provided, it is set as the new modified value.
parent()
Returns the Entities::Backend instance that stores this object.
add_feature( $feature_name )
Adds the feature named $feature_name
to the plan. Croaks if the feature does not exist, warns if the plan already has that feature. Returns the plan object itself.
drop_feature( $feature_name )
Removes the feature named $feature_name
from the plan. This only removes the feature if it was directly provided to the plan, and not through inheritance, so it's possible the plan will still have that feature after removal if it inherits it from a plan that provides it.
Warns if the plan doesn't have that feature, doesn't croak if the feature does not exist at all. Returns the plan object itself.
has_direct_feature( $feature_name )
Returns a true value if the plan was directly provided with the feature named $feature_name
.
take_from_plan( $plan_name )
Setup an inheritance from the plan named $plan_name
. This plan will then inherit all features from that plan. Croaks if the provided plan does not exist, warns if the plan object already inherits from it. Returns the plan object itself.
dont_take_from_plan( $plan_name )
This badly named method removes the inheritance between the current plan object and the plan named $plan_name
. Warns if the plan doesn't inherit from the provided plan. Doesn't croak if $plan_name
can't be found.
Returns the plan object itself.
get_plan( $plan_name )
Returns the plan object of the plan named $plan_name
.
METHOD MODIFIERS
The following list documents any method modifications performed through the magic of Moose.
around qw/plans features/
If the plans()
and features()
methods are called with no arguments and in list context - will automatically dereference the array-ref into arrays.
after anything_that_changes_object
Automatically saves the object to the backend after any method that changed it was executed. Also updates the 'modified' attribute with the current time before saving. Note, however, that the plans()
and features()
methods are not here, since they are only meant to be used for writing internally.
SEE ALSO
AUTHOR
Ido Perlmuter, <ido at ido50 dot net>
BUGS
Please report any bugs or feature requests to bug-entities at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Entities. 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 Entities::Plan
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2010-2013 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.