| 1 | package Catalyst::Authentication::Store::Tangram::User; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use base qw/Catalyst::Authentication::User/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use Carp qw/confess/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use Scalar::Util qw/blessed/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use overload '""' => sub { shift->id }, fallback => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | __PACKAGE__->mk_accessors(qw/_tangram _storage _store _roles/); | |||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 15 | 1 | my ($class, $storage, $tangram_ob, $store) = @_; | |||||||||
| 16 | 1 | bless { _storage => $storage, _tangram => $tangram_ob, _store => $store }, $class; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 3 | *get_object = \&_tangram; | |||||||||
| 20 | |||||||||||
| 21 | 3 | ▶ | sub id { | ||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 3 | my ($self) = @_; | |||||||||
| 23 | 3 | return $self->_storage->id($self->_tangram); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | sub roles { | ||||||||
|
Subroutine
roles: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 27 | 1 | my ($self) = @_; | |||||||||
| 28 | 1 | ▶ | $self->_roles([$self->_store->lookup_roles($self)]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | unless $self->_roles; | ||||||||||
| 30 | 1 | return @{ $self->_roles }; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub supported_features { | ||||||||
|
Subroutine
supported_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 34 | return { | ||||||||||
| 35 | 0 | password => { self_check => 0, }, | |||||||||
| 36 | session => 1, | ||||||||||
| 37 | roles => { self_check => 0, }, | ||||||||||
| 38 | }; | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.3
| |||||||||||
| 42 | 1 | my $self = shift; | |||||||||
| 43 | |||||||||||
| 44 | 1 | ( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ ); | |||||||||
| 45 | |||||||||||
| 46 | 1 | ▶ | return if $method eq "DESTROY"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | confess("Could not call method $method on tangram class " . | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | blessed($self->_tangram)) unless $self->_tangram->can($method); | ||||||||||
| 50 | 1 | $self->_tangram->$method; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 3 | 1; | |||||||||
| 54 | |||||||||||
| 55 | =head1 NAME | ||||||||||
| 56 | |||||||||||
| 57 | Catalyst::Authentication::Store::Tangram::User - A thin adaptor | ||||||||||
| 58 | to adapt any Tangram class to behave as needed by | ||||||||||
| 59 | L<Catalyst::Authentication::User> | ||||||||||
| 60 | |||||||||||
| 61 | =head1 SYNOPSIS | ||||||||||
| 62 | |||||||||||
| 63 | $c->user->id; # Returns unique user ID | ||||||||||
| 64 | $c->user->get('email_address'); # Retrieve value from the underlying Tangram object. | ||||||||||
| 65 | $c->user->get_object; # Get the underlying Tangram object yourself. | ||||||||||
| 66 | |||||||||||
| 67 | =head1 DESCRIPTION | ||||||||||
| 68 | |||||||||||
| 69 | The Catalyst::Authentication::Store::Tangram::User class encapsulates any | ||||||||||
| 70 | Tangram class in the L<Catalyst::Authentication::User> interface. An instance | ||||||||||
| 71 | of it will be returned by C<< $c->user >> when using | ||||||||||
| 72 | L<Catalyst::Authentication::Store::Tangram>. Methods not defined in this module | ||||||||||
| 73 | are passed through to the Tangram object. The object stringifies to the | ||||||||||
| 74 | Tangram ID. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 METHODS | ||||||||||
| 77 | |||||||||||
| 78 | =head2 new ($class, $storage, $tangram_object) | ||||||||||
| 79 | |||||||||||
| 80 | Simple constructor | ||||||||||
| 81 | |||||||||||
| 82 | =head2 id | ||||||||||
| 83 | |||||||||||
| 84 | Unique Tangram ID for this object | ||||||||||
| 85 | |||||||||||
| 86 | =head2 get_object | ||||||||||
| 87 | |||||||||||
| 88 | Returns the underlying Tangram user object. | ||||||||||
| 89 | |||||||||||
| 90 | =head2 roles | ||||||||||
| 91 | |||||||||||
| 92 | Returns the list of roles which this user is authorised to do. | ||||||||||
| 93 | |||||||||||
| 94 | =head2 supported_features | ||||||||||
| 95 | |||||||||||
| 96 | Returns hashref of features that this Authentication::User subclass supports. | ||||||||||
| 97 | |||||||||||
| 98 | =head1 AUTHOR | ||||||||||
| 99 | |||||||||||
| 100 | Tomas Doran, <bobtfish at bobtfish dot net> | ||||||||||
| 101 | |||||||||||
| 102 | With thanks to state51, my employer, for giving me the time to work on this. | ||||||||||
| 103 | |||||||||||
| 104 | =head1 BUGS | ||||||||||
| 105 | |||||||||||
| 106 | All complex software has bugs, and I'm sure that this module is no exception. | ||||||||||
| 107 | |||||||||||
| 108 | Please report bugs through the rt.cpan.org bug tracker. | ||||||||||
| 109 | |||||||||||
| 110 | =head1 COPYRIGHT | ||||||||||
| 111 | |||||||||||
| 112 | Copyright (c) 2008, state51. Some rights reserved. | ||||||||||
| 113 | |||||||||||
| 114 | This module is free software; you can use, redistribute, and modify it under | ||||||||||
| 115 | the same terms as Perl 5.8.x. | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | |||||||||||