-
Notifications
You must be signed in to change notification settings - Fork 4
/
PriceRange.pm
49 lines (37 loc) · 1016 Bytes
/
PriceRange.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package VegGuide::PriceRange;
use strict;
use warnings;
use VegGuide::Schema;
use VegGuide::AlzaboWrapper (
table => VegGuide::Schema->Schema->PriceRange_t );
my %PriceRanges;
my %PriceRangesByName;
my %PriceRangeSymbolsOnly;
BEGIN {
%PriceRanges = (
map {
$_->select('price_range_id') =>
VegGuide::PriceRange->SUPER::new( object => $_ )
} VegGuide::Schema->Connect->PriceRange_t->all_rows->all_rows
);
%PriceRangesByName
= map { $_->description() => $_ } values %PriceRanges;
%PriceRangeSymbolsOnly
= map { $_->price_range_id() => ( $_->description =~ /^(\$+)/ ) }
values %PriceRanges;
}
sub new {
my $class = shift;
my %p = @_;
return $PriceRanges{ $p{price_range_id} };
}
sub symbols_only {
my $self = shift;
return $PriceRangeSymbolsOnly{ $self->price_range_id() };
}
sub All {
return
sort { $a->display_order() <=> $b->display_order() }
values %PriceRanges;
}
1;