« blib/lib/UR/Object/Type/AccessorWriter/Product.pm
↑ Summary
blib/lib/UR/Object/Type/View/Default/Text.pm »
| 1 | |||
| 2 | package UR::Object::Type::AccessorWriter::Sum; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | require UR; | ||
| 7 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 8 | |||
| 9 | sub calculate { | ||
| 10 | my $self = shift; | ||
| 11 | my $object = shift; | ||
| 12 | my $properties = shift; | ||
| 13 | my $sum = 0; | ||
| 14 | for my $property (@$properties) { | ||
| 15 | $sum += $object->$property | ||
| 16 | } | ||
| 17 | return $sum; | ||
| 18 | }; | ||
| 19 | |||
| 20 | 1; | ||
| 21 | |||
| 22 | =pod | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | UR::Object::Type::AccessorWriter::Sum - Implements a calculation accessor which sums the values of its properties | ||
| 27 | |||
| 28 | =cut |