| 1 | package Data::HTML::Element::Option; | ||
| 2 | |||
| 3 | 11 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 11 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 0 | ▶ | use Data::HTML::Element::Utils qw(check_data check_data_type); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Error::Pure qw(err); | ||
| 8 | use List::Util 1.33 qw(none); | ||
| 9 | use Mo qw(build is); | ||
| 10 | use Mo::utils 0.26 qw(check_array check_bool check_number); | ||
| 11 | use Mo::utils::CSS 0.02 qw(check_css_class); | ||
| 12 | |||
| 13 | our $VERSION = 0.17; | ||
| 14 | |||
| 15 | has css_class => ( | ||
| 16 | is => 'ro', | ||
| 17 | ); | ||
| 18 | |||
| 19 | has data => ( | ||
| 20 | default => [], | ||
| 21 | is => 'ro', | ||
| 22 | ); | ||
| 23 | |||
| 24 | has data_type => ( | ||
| 25 | is => 'ro', | ||
| 26 | ); | ||
| 27 | |||
| 28 | has disabled => ( | ||
| 29 | is => 'ro', | ||
| 30 | ); | ||
| 31 | |||
| 32 | has id => ( | ||
| 33 | is => 'ro', | ||
| 34 | ); | ||
| 35 | |||
| 36 | has label => ( | ||
| 37 | is => 'ro', | ||
| 38 | ); | ||
| 39 | |||
| 40 | has selected => ( | ||
| 41 | is => 'ro', | ||
| 42 | ); | ||
| 43 | |||
| 44 | has value => ( | ||
| 45 | is => 'ro', | ||
| 46 | ); | ||
| 47 | |||
| 48 | sub BUILD { | ||
| 49 | my $self = shift; | ||
| 50 | |||
| 51 | # Check CSS class. | ||
| 52 | check_css_class($self, 'css_class'); | ||
| 53 | |||
| 54 | # Check data type. | ||
| 55 | check_data_type($self); | ||
| 56 | |||
| 57 | # Check data based on type. | ||
| 58 | check_data($self); | ||
| 59 | |||
| 60 | # Check disabled. | ||
| 61 | if (! defined $self->{'disabled'}) { | ||
| 62 | $self->{'disabled'} = 0; | ||
| 63 | } | ||
| 64 | check_bool($self, 'disabled'); | ||
| 65 | |||
| 66 | # Check selected. | ||
| 67 | if (! defined $self->{'selected'}) { | ||
| 68 | $self->{'selected'} = 0; | ||
| 69 | } | ||
| 70 | check_bool($self, 'selected'); | ||
| 71 | |||
| 72 | return; | ||
| 73 | } | ||
| 74 | |||
| 75 | 1; | ||
| 76 | |||
| 77 | __END__ | ||