Entities::Customer - An abstract entity that owns users and subscribes to plans.
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.
NOTE: you are not meant to create customer objects directly, but only through the
new_customer() method in Entities.
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.
Returns an array of all plan objects this customer is subscribed to.
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 an array of all feature objects this customer has.
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.
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.
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
The following methods are consumed by this class from the Abilities::Features Moose role. See the documentation for that role for more information on these methods.
The following list documents any method modifications performed through the magic of Moose.
_features() methods are called with no arguments and in list context - will automatically dereference the array-ref into arrays.
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
features() methods are not here, since they are only meant to be used for writing internally.
<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.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2010 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.