| 1 | package Net::NATS::ConnectInfo; | ||
| 2 | |||
| 3 | use Class::XSAccessor { | ||
| 4 | constructors => [ '_new' ], | ||
| 5 | accessors => [ | ||
| 6 | 'verbose', | ||
| 7 | 'pedantic', | ||
| 8 | 'ssl_required', | ||
| 9 | 'auth_token', | ||
| 10 | 'user', | ||
| 11 | 'pass', | ||
| 12 | 'name', | ||
| 13 | 'lang', | ||
| 14 | 'version', | ||
| 15 | ], | ||
| 16 | }; | ||
| 17 | |||
| 18 | sub new { | ||
| 19 | my $class = shift; | ||
| 20 | my $self = $class->_new(@_); | ||
| 21 | |||
| 22 | $self->verbose(0) unless $self->verbose; | ||
| 23 | $self->pedantic(0) unless $self->pedantic; | ||
| 24 | $self->ssl_required(0) unless $self->ssl_required; | ||
| 25 | |||
| 26 | return $self; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub TO_JSON { | ||
| 30 | my $self = shift; | ||
| 31 | my $hash = { %{ $self } }; | ||
| 32 | $hash->{verbose} = $self->verbose ? \1 : \0; | ||
| 33 | $hash->{pedantic} = $self->pedantic ? \1 : \0; | ||
| 34 | $hash->{ssl_required} = $self->ssl_required ? \1 : \0; | ||
| 35 | return $hash; | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; |