Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:perl:CPAN-O
perl-Object-Botox
perl-Object-Botox.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-Object-Botox.spec of Package perl-Object-Botox
# # spec file for package perl-Object-Botox # # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # 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 http://bugs.opensuse.org/ # Name: perl-Object-Botox Version: 1.15 Release: 0 %define cpan_name Object-Botox Summary: Simple Object Constructor with Accessor, Prototyping and Default-Setting[cut] License: Artistic-1.0 or GPL-1.0+ Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Object-Botox/ Source0: http://www.cpan.org/authors/id/M/ME/MEETTYA/%{cpan_name}-%{version}.tar.gz BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(MRO::Compat) >= 0.11 BuildRequires: perl(Module::Build) >= 0.380000 BuildRequires: perl(Test::More) >= 0.94 Requires: perl(MRO::Compat) >= 0.11 %{perl_requires} %description Object::Botox - simple constructor and properties prototyper whith checking of properties existans. To create parent module: package Parent; use Botox; # strictly named constant PROTOTYPE ! use constant PROTOTYPE => { 'prop1_ro' => 1 , 'prop2' => 'abcde' }; sub show_prop1{ # It`s poinlessly - indeed property IS A accessor itself my ( $self ) = @_; return $self->prop1; } sub set_prop1{ # It`s NEEDED for RO aka protected on write property my ( $self, $value ) = @_; $self->prop1($value); } sub parent_sub{ # It`s class method itself my $self = shift; return $self->prop1; } 1; after that we are create instanse: package main; use Data::Dumper; # change default value for prop1 my $foo = new Parent( { prop1 => 888888 } ); print Dumper($foo); outputs get to us: $VAR1 = bless( { 'Parent::prop1' => 888888, 'Parent::prop2' => 'abcde' }, 'Parent' ); properties may have _rw[default] or _ro acess mode and inheritated. eval{ $foo->prop1(-23) }; print $@."\n"; output somthing like this: Can`t change RO properties |prop1| to |-23| in object Parent from main at ./test_more.t line 84 to deal (write to) with this properties we are must create accessor . Also all of properties are inheritanced. package Child; use base 'Parent'; use constant PROTOTYPE => { 'prop1' => 48, 'prop5' => 55, 'prop8_ro' => 'tetete' }; 1; give to us something like this $VAR1 = bless( { 'Child::prop5' => 55, 'Child::prop2' => 'abcde', 'Child::prop1' => 48, 'Child::prop8' => 'tetete' }, 'Child' ); Chainings - all setter return $self in success, so its chained $baz->prop1(88)->prop2('loreum ipsum'); %prep %setup -q -n %{cpan_name}-%{version} %build %{__perl} Build.PL installdirs=vendor ./Build build flags=%{?_smp_mflags} %check ./Build test %install ./Build install destdir=%{buildroot} create_packlist=0 %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes ignore.txt 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