blib/lib/WebService/Mattermost/V4/API/Object/Role/BelongingToUser.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 14 | 15 | 93.3 |
branch | 1 | 2 | 50.0 |
condition | 1 | 3 | 33.3 |
subroutine | 5 | 6 | 83.3 |
pod | n/a | ||
total | 21 | 26 | 80.7 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package WebService::Mattermost::V4::API::Object::Role::BelongingToUser; 2: 3: # ABSTRACT: Mark an object as belonging to a user. 4: 5: use Moo::Role; 6: use Types::Standard qw(InstanceOf Maybe Str); 7: 8: use WebService::Mattermost::Helper::Alias 'view'; 9: 10: ################################################################################ 11: 12: has creator_id => (is => 'ro', isa => Maybe[Str], lazy => 1, builder => 1); 13: has [ qw(user created_by) ] => (is => 'ro', isa => Maybe[InstanceOf[view 'User']], lazy => 1, builder => 1); 14: 15: ################################################################################ 16: 17: sub _build_creator_id { 18: my $self = shift; 19: 20: return $self->raw_data->{creator_id} 21: || $self->raw_data->{owner_id} 22: || $self->raw_data->{user_id}; 23: } 24: 25: sub _build_created_by { 26: my $self = shift; 27: 28: return unless $self->creator_id; 29: return $self->api->user->get($self->creator_id)->item; 30: } 31: 32: sub _build_user { shift->created_by } 33: 34: ################################################################################ 35: 36: 1; 37: 38: __END__ 39: 40: =pod 41: 42: =encoding UTF-8 43: 44: =head1 NAME 45: 46: WebService::Mattermost::V4::API::Object::Role::BelongingToUser - Mark an object as belonging to a user. 47: 48: =head1 VERSION 49: 50: version 0.28 51: 52: =head1 DESCRIPTION 53: 54: Link a view object to its creator. 55: 56: =head2 ATTRIBUTES 57: 58: =over 4 59: 60: =item C<creator_id> 61: 62: The creator's string ID. 63: 64: =item C<created_by|user> 65: 66: Linked L<WebService::Mattermost::V4::API::Object::User> object. 67: 68: =back 69: 70: =head1 AUTHOR 71: 72: Mike Jones <mike@netsplit.org.uk> 73: 74: =head1 COPYRIGHT AND LICENSE 75: 76: This software is Copyright (c) 2020 by Mike Jones. 77: 78: This is free software, licensed under: 79: 80: The MIT (X11) License 81: 82: =cut 83: |