Entities::Customer - An abstract entity that owns users and subscribes to plans.
version 0.5
used internally, see L<Entities>
A customer is a company, organization or individual that have subscribed to use the services of your ability-based webapp, possibly paying for it. This customer entity can subscribe to different <plans|Entities::Plan> and use the <features|Entities::Feature> provided with these plans (or explicitely given to the customer). The customer is the parent of one or more <users|Entities::User>. If a user belongs to a certain company, they will only be able to perform actions according to the limits and features provided with the customer's plans.
This entity class does the Abilities::Features Moose role.
does
NOTE: you are not meant to create customer objects directly, but only through the new_customer() method in Entities.
new_customer()
Creates a new instance of this module. Only 'name' and 'email_address' are required.
Returns the ID of the customer, if set.
Returns a true value if the customer object has an ID attribute.
Sets the ID of the customer object to the provided value. Only to be used internally.
Returns the name of the customer.
Returns the email address of the customer. In case of a company or organization, this should probably be a certain contact in the organization, possibly in the financial department.
Changes the email address of the customer to the provided value.
In scalar context, returns an array-ref of all plan names that customer is subscribed to. In list context, returns an array. If an array-ref of plan names is provided, it will replace the current list of plans of the customer.
Returns a true value if the customer is subscribed to any plan.
In scalar context, returns an array-ref of all feature names that have been provided for the customer (directly! not through plans). In list context returns an array. If an array-ref of feature names is provided, it will replace the current list of features the customer owns.
Returns a true value if the customer has been provided with any feature directly.
Returns a DateTime object in the time the customer object has been created.
Returns a DateTime object in the last time the customer object has been modified. If a DateTime object is provided, it will be set as the new value of this attribute.
Returns the Entities::Backend instance that stores this object.
Subscribes the customer to the plan named $plan_name. Croaks if the plan does not exist, warns if the customer is already subscribed to it. Returns the customer object itself.
$plan_name
Cancels the customer's subscription to the plan named $plan_name. Warns if the customer is not subscribed to that plan. Will not croak if the plan doesn't exist. Returns the customer object itself.
Gives the customer the feature named $feature_name. Croaks if the feature does not exist, warns if it's already provided to the customer. Returns the customer object itself.
$feature_name
Removes the feature named $feature_name from the customer. This only removes the feature if it was directly provided to the customer, and not through plans, so it's possible the customer might still have that feature after removal if they are still subscribed to a plan that provides it.
Warns if the customer doesn't have that feature, doesn't croak if the feature does not exist at all. Returns the customer object itself.
Returns a true value if the customer was directly provided with the feature named $feature_name.
Returns the plan object of the plan named $plan_name.
The following list documents any method modifications performed through the magic of Moose.
If the plans() and features() methods are called with no arguments and in list context - will automatically dereference the array-ref into arrays.
plans()
features()
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.
Entities.
Ido Perlmuter, <ido at ido50 dot net>
<ido at ido50 dot net>
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.
bug-entities at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Entities::Customer
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Entities
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Entities
CPAN Ratings
http://cpanratings.perl.org/d/Entities
Search CPAN
http://search.cpan.org/dist/Entities/
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.
To install Entities, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Entities
CPAN shell
perl -MCPAN -e shell install Entities
For more information on module installation, please visit the detailed CPAN module installation guide.