Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-Class-Tangram
perl-Class-Tangram.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-Class-Tangram.spec of Package perl-Class-Tangram
# # spec file for package perl-Class-Tangram # # Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: perl-Class-Tangram Version: 1.57 Release: 0 %define cpan_name Class-Tangram Summary: Tangram-friendly classes, DWIM attributes License: CHECK(Artistic-1.0 OR GPL-1.0-or-later) Group: Development/Libraries/Perl URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/S/SA/SAMV/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml Patch0: Class-Tangram-1.57-RT108841.patch BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Date::Manip) >= 5.21 BuildRequires: perl(Set::Object) >= 1.04 Requires: perl(Date::Manip) >= 5.21 Requires: perl(Set::Object) >= 1.04 %{perl_requires} %description Class::Tangram is a tool for defining objects attributes. Simply define your object's fields/attributes using the same data structure introduced in _A Guided Tour of Tangram_ (see SEE ALSO) and detailed in Tangram::Schema, and you get objects that work As You'd Expect(tm). Class::Tangram has no dependancy upon Tangram, and vice versa. Neither requires anything special of your objects, nor do they insert any special fields into your objects. This is a very important feature with innumerable benefits, and few (if any) other object persistence tools have this feature. So, fluff aside, let's run through how you use Class::Tangram to make objects. First, you decide upon the attributes your object is going to have. You might do this using UML, or you might pick an existing database table and declare each column to be an attribute (you can leave out "id"; that one is implicit; also, leave out foreign keys until later). Your object should use Class::Tangram as a base class; use base qw(Class::Tangram) or for older versions of perl: use Class::Tangram; use vars qw(@ISA); @ISA = qw(Class::Tangram) You should then define a '$fields' variable in the scope of the package, that is a *hash* from attribute *types* (see Tangram::Type) to either an *array* of *attribute names*, or another *hash* from *attribute names* to *options hashes* (or 'undef'). The layout of this structure coincides exactly with the 'fields' portion of a tangram schema (see Tangram::Schema), though there are some extra options available. This will hereon in be referred to as the `object schema' or just `schema'. For example, package Orange; use base qw(Class::Tangram); our $fields = { int => { juiciness => undef, segments => { # this code reference is called when this # attribute is set, to check the value is # OK - note, no object is passed, this is for # simple marshalling only. check_func => sub { die "too many segments" if (${(shift)} > 30); }, # the default for this attribute. init_default => 7, }, }, ref => { grower => { }, }, # 'required' attributes - insist that these fields are # set, both with constructor and set()/set_X methods string => { # true: 'type' must have non-empty value (for # strings) or be logically true (for other types) type => { required => 1 }, # false: 'tag' must be defined but may be empty tag => { required => '' }, }, # fields allowed by Class::Tangram but not ever # stored by Tangram - no type checking by default transient => [ qw(_tangible) ], }; It is of critical importance to your sanity that you understand how anonymous hashes and anonymous arrays work in Perl. Some additional features are used above that have not yet been introduced, but you should be able to look at the above data structure and see that it satisfies the conditions stated in the paragraph before it. If it is hazy, I recommend reading perlref or perlreftut. When the schema for the object is first imported (see Schema import), Class::Tangram defines accessor functions for each of the attributes defined in the schema. These accessor functions are then available as '$object->function' on created objects. By virtue of inheritance, various other methods are available. From Class::Tangram 1.12 onwards, perl's 'AUTOLOAD' feature is not used to implement accessors; closures are compiled when the class is first used. %prep %autosetup -n %{cpan_name}-%{version} -p1 %build PERL_USE_UNSAFE_INC=1 perl Makefile.PL INSTALLDIRS=vendor make %{?_smp_mflags} %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes README %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor