JavaScript::Code::Accessor - A Accessor Class


JavaScript-Code documentation Contained in the JavaScript-Code distribution.

Index


Code Index:

NAME

Top

JavaScript::Code::Accessor - A Accessor Class

SYNOPSIS

    use base qw[ JavaScript::Code::Accessor ];

DESCRIPTION

Accessor Class

METHDOS

Top

JavaScript::Code::Accessor->new( %args | \%args )

Takes a hash or a hashref as initialization arguments.

SEE ALSO

Top

JavaScript::Code, Class::Accessor::Chained::Fast

AUTHOR

Top

Sascha Kiefer, esskar@cpan.org

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


JavaScript-Code documentation Contained in the JavaScript-Code distribution.
package JavaScript::Code::Accessor;

use strict;
use vars qw[ $VERSION ];
use base qw[ Class::Accessor::Chained::Fast ];
use Carp ();

use Scalar::Util ();

$VERSION = '0.08';

sub new {
    my $obj   = shift;
    my $class = ref $obj || $obj;

    return $class->SUPER::new( $class->__args(@_) );
}

sub __args {
    my $self = shift;

    return {} unless @_;

    my $ref = @_ ? Scalar::Util::reftype( $_[0] ) || '' : '';
    my %args =
      $ref eq 'HASH'
      ? %{ shift() }
      : @_;

    return \%args;
}

1;