File Coverage

blib/lib/Data/Object/Struct.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 2 0.0
total 36 38 94.7


line stmt bran cond sub pod time code
1             package Data::Object::Struct;
2              
3 1     1   32579 use 5.014;
  1         4  
4              
5 1     1   5 use strict;
  1         3  
  1         26  
6 1     1   6 use warnings;
  1         2  
  1         65  
7 1     1   8 use routines;
  1         2  
  1         8  
8              
9 1     1   2264 use Data::Object::Class;
  1         1026  
  1         12  
10              
11             with 'Data::Object::Role::Buildable';
12             with 'Data::Object::Role::Immutable';
13             with 'Data::Object::Role::Proxyable';
14              
15             our $VERSION = '2.00'; # VERSION
16              
17 1     1 0 25294 method build_self($args) {
  1         4  
  1         3  
18 1         10 %$self = %$args;
19              
20 1         7 $self->immutable;
21              
22 1         94 return $self;
23             }
24              
25 8     8 0 7389 method build_proxy($package, $method) {
  8         21  
  8         10  
26 8 100   7   40 return sub { $self->{$method} } if exists $self->{$method};
  7         144  
27              
28 1         10 return undef;
29             }
30              
31             1;
32              
33             =encoding utf8
34              
35             =head1 NAME
36              
37             Data::Object::Struct
38              
39             =cut
40              
41             =head1 ABSTRACT
42              
43             Struct Class for Perl 5
44              
45             =cut
46              
47             =head1 SYNOPSIS
48              
49             package main;
50              
51             use Data::Object::Struct;
52              
53             my $person = Data::Object::Struct->new(
54             fname => 'Aron',
55             lname => 'Nienow',
56             cname => 'Jacobs, Sawayn and Nienow'
57             );
58              
59             # $person->fname # Aron
60             # $person->lname # Nienow
61             # $person->cname # Jacobs, Sawayn and Nienow
62              
63             # $person->mname
64             # Error!
65              
66             # $person->mname = 'Clifton'
67             # Error!
68              
69             # $person->{mname} = 'Clifton'
70             # Error!
71              
72             =cut
73              
74             =head1 DESCRIPTION
75              
76             This package provides a class that creates struct-like objects which bundle
77             attributes together, is immutable, and provides accessors, without having to
78             write an explicit class.
79              
80             =cut
81              
82             =head1 INTEGRATES
83              
84             This package integrates behaviors from:
85              
86             L<Data::Object::Role::Buildable>
87              
88             L<Data::Object::Role::Immutable>
89              
90             L<Data::Object::Role::Proxyable>
91              
92             =cut
93              
94             =head1 AUTHOR
95              
96             Al Newkirk, C<awncorp@cpan.org>
97              
98             =head1 LICENSE
99              
100             Copyright (C) 2011-2019, Al Newkirk, et al.
101              
102             This is free software; you can redistribute it and/or modify it under the terms
103             of the The Apache License, Version 2.0, as elucidated in the L<"license
104             file"|https://github.com/iamalnewkirk/data-object-struct/blob/master/LICENSE>.
105              
106             =head1 PROJECT
107              
108             L<Wiki|https://github.com/iamalnewkirk/data-object-struct/wiki>
109              
110             L<Project|https://github.com/iamalnewkirk/data-object-struct>
111              
112             L<Initiatives|https://github.com/iamalnewkirk/data-object-struct/projects>
113              
114             L<Milestones|https://github.com/iamalnewkirk/data-object-struct/milestones>
115              
116             L<Contributing|https://github.com/iamalnewkirk/data-object-struct/blob/master/CONTRIBUTE.md>
117              
118             L<Issues|https://github.com/iamalnewkirk/data-object-struct/issues>
119              
120             =cut