File Coverage

blib/lib/Stancer/Role/Amount/Read.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Stancer::Role::Amount::Read;
2              
3 15     15   167759 use 5.020;
  15         65  
4 15     15   93 use strict;
  15         36  
  15         484  
5 15     15   76 use warnings;
  15         56  
  15         1440  
6              
7             # ABSTRACT: Amount read-only role
8             our $VERSION = '1.0.3'; # VERSION
9              
10 15     15   527 use Stancer::Core::Types qw(Amount Maybe Currency);
  15         37  
  15         1332  
11              
12 15     15   100 use Moo::Role;
  15         35  
  15         152  
13              
14             requires qw(_add_modified _attribute_builder);
15              
16 15     15   10867 use namespace::clean;
  15         40  
  15         152  
17              
18              
19             has amount => (
20             is => 'rwp',
21             isa => Maybe[Amount],
22 8     8   353 builder => sub { $_[0]->_attribute_builder('amount') },
23             lazy => 1,
24             predicate => 1,
25             trigger => sub { $_[0]->_add_modified('amount') },
26             );
27              
28              
29             has currency => (
30             is => 'rwp',
31             isa => Maybe[Currency],
32 8     8   430 builder => sub { $_[0]->_attribute_builder('currency') },
33             coerce => sub { defined $_[0] ? lc $_[0] : $_[0] },
34             lazy => 1,
35             predicate => 1,
36             trigger => sub { $_[0]->_add_modified('currency') },
37             );
38              
39             1;
40              
41             __END__
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Stancer::Role::Amount::Read - Amount read-only role
50              
51             =head1 VERSION
52              
53             version 1.0.3
54              
55             =head1 ATTRIBUTES
56              
57             =head2 C<amount>
58              
59             Read-only integer.
60              
61             Amount.
62              
63             =head2 C<currency>
64              
65             Read-only string.
66              
67             Currency.
68              
69             =head1 USAGE
70              
71             =head2 Logging
72              
73              
74              
75             We use the L<Log::Any> framework for logging events.
76             You may tell where it should log using any available L<Log::Any::Adapter> module.
77              
78             For example, to log everything to a file you just have to add a line to your script, like this:
79             #! /usr/bin/env perl
80             use Log::Any::Adapter (File => '/var/log/payment.log');
81             use Stancer::Role::Amount::Read;
82              
83             You must import C<Log::Any::Adapter> before our libraries, to initialize the logger instance before use.
84              
85             You can choose your log level on import directly:
86             use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info');
87              
88             Read the L<Log::Any> documentation to know what other options you have.
89              
90             =cut
91              
92             =head1 SECURITY
93              
94             =over
95              
96             =item *
97              
98             Never, never, NEVER register a card or a bank account number in your database.
99              
100             =item *
101              
102             Always uses HTTPS in card/SEPA in communication.
103              
104             =item *
105              
106             Our API will never give you a complete card/SEPA number, only the last four digits.
107             If you need to keep track, use these last four digit.
108              
109             =back
110              
111             =cut
112              
113             =head1 BUGS
114              
115             Please report any bugs or feature requests on the bugtracker website
116             L<https://gitlab.com/wearestancer/library/lib-perl/-/issues> or by email to
117             L<bug-stancer@rt.cpan.org|mailto:bug-stancer@rt.cpan.org>.
118              
119             When submitting a bug or request, please include a test-file or a
120             patch to an existing test-file that illustrates the bug or desired
121             feature.
122              
123             =head1 AUTHOR
124              
125             Joel Da Silva <jdasilva@cpan.org>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is Copyright (c) 2018-2024 by Stancer / Iliad78.
130              
131             This is free software, licensed under:
132              
133             The Artistic License 2.0 (GPL Compatible)
134              
135             =cut