« Chart/Plotly/Trace/Contour/Colorbar/Tickformatstop.pm
↑ Summary
Chart/Plotly/Trace/Contour/Colorbar/Title/Font.pm »
| 1 | package Chart::Plotly::Trace::Contour::Colorbar::Tickformatstops; | ||
| 2 | use Moose; | ||
| 3 | use MooseX::ExtraArgs; | ||
| 4 | use Moose::Util::TypeConstraints qw(enum union); | ||
| 5 | |||
| 6 | our $VERSION = '0.042'; # VERSION | ||
| 7 | |||
| 8 | sub TO_JSON { | ||
| 9 | my $self = shift; | ||
| 10 | my $extra_args = $self->extra_args // {}; | ||
| 11 | my $meta = $self->meta; | ||
| 12 | my %hash = %$self; | ||
| 13 | for my $name ( sort keys %hash ) { | ||
| 14 | my $attr = $meta->get_attribute($name); | ||
| 15 | if ( defined $attr ) { | ||
| 16 | my $value = $hash{$name}; | ||
| 17 | my $type = $attr->type_constraint; | ||
| 18 | if ( $type && $type->equals('Bool') ) { | ||
| 19 | $hash{$name} = $value ? \1 : \0; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
| 23 | %hash = ( %hash, %$extra_args ); | ||
| 24 | delete $hash{'extra_args'}; | ||
| 25 | if ( $self->can('type') && ( !defined $hash{'type'} ) ) { | ||
| 26 | $hash{type} = $self->type(); | ||
| 27 | } | ||
| 28 | return \%hash; | ||
| 29 | } | ||
| 30 | |||
| 31 | has items => ( is => "rw", ); | ||
| 32 | |||
| 33 | __PACKAGE__->meta->make_immutable(); | ||
| 34 | 1; | ||
| 35 | |||
| 36 | __END__ |