עידו פרלמוטר (Ido Perlmuter) > Entities-0.2 > Entities::Customer

Download:
Entities-0.2.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.2   Source   Latest Release: Entities-0.5

NAME ^

Entities::Customer - An abstract entity that owns users and subscribes to plans.

VERSION ^

version 0.2

SYNOPSIS ^

        used internally, see L<Entities>

DESCRIPTION ^

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.

NOTE: you are not meant to create customer objects directly, but only through the new_customer() method in Entities.

METHODS ^

new( name => 'somecustomer', email_address => 'customer@customer.com', [ features => [], plans => [], created => $dt_obj, modified => $other_dt_obj, parent => $entities_obj, id => 123 ] )

Creates a new instance of this module. Only 'name' and 'email_address' are required.

id()

Returns the ID of the customer, if set.

has_id()

Returns a true value if the customer object has an ID attribute.

_set_id( $id )

Sets the ID of the customer object to the provided value. Only to be used internally.

name()

Returns the name of the customer.

email_address()

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.

set_email_address( $email )

Changes the email address of the customer to the provided value.

_plans( [\@plans] )

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.

has_plans()

Returns a true value if the customer is subscribed to any plan.

plans()

Returns an array of all plan objects this customer is subscribed to.

_features( [\@features] )

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.

has_features()

Returns a true value if the customer has been provided with any feature directly.

features()

Returns an array of all feature objects this customer has.

created()

Returns a DateTime object in the time the customer object has been created.

modified( [$dt] )

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.

parent()

Returns the Entities::Backend instance that stores this object.

add_plan( $plan_name )

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.

drop_plan( $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.

add_feature( $feature_name )

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.

drop_feature( $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.

has_direct_feature( $feature_name )

Returns a true value if the customer was directly provided with the feature named $feature_name.

METHODS CONSUMED FROM Abilities::Features ^

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.

has_feature( $feature_name | @feature_names )

in_plan( $plan_name | @plan_names )

inherits_from_plan( $plan_name | @plan_names )

all_features()

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 ^

Entities.

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::Customer

You can also look for information at:

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: