package Venus::Core::Class;

use 5.018;

use strict;
use warnings;

no warnings 'once';

use base 'Venus::Core';

# IMPORTS

use Venus::Hook;

# HOOKS

{
  no warnings 'once';

  *clone = *Venus::Hook::CLONE;

  *does = *Venus::Hook::DOES;

  *meta = *Venus::Hook::META;

  *new = *Venus::Hook::BLESS;

  *BUILD = *Venus::Hook::BUILD_FOR_CLASS;

  *CONSTRUCT = *Venus::Hook::CONSTRUCT_FOR_CLASS;

  *DECONSTRUCT = *Venus::Hook::DECONSTRUCT_FOR_CLASS;

  *DESTROY = *Venus::Hook::DESTROY_FOR_CLASS;

  *EXPORT = *Venus::Hook::EXPORT_FOR_CLASS;

  *IMPORT = *Venus::Hook::IMPORT_FOR_CLASS;
}

# METHODS

sub import {
  my ($self, @args) = @_;

  my $target = caller;

  $self->USE($target);

  return $self->IMPORT($target, @args);
}

sub unimport {
  my ($self, @args) = @_;

  my $target = caller;

  return $self->UNIMPORT($target, @args);
}

1;



=head1 NAME

Venus::Core::Class - Class Base Class

=cut

=head1 ABSTRACT

Class Base Class for Perl 5

=cut

=head1 SYNOPSIS

  package User;

  use base 'Venus::Core::Class';

  package main;

  my $user = User->new(
    fname => 'Elliot',
    lname => 'Alderson',
  );

  # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')

=cut

=head1 DESCRIPTION

This package provides a class base class with class building and object
construction lifecycle hooks.

=cut

=head1 INHERITS

This package inherits behaviors from:

L<Venus::Core>

=cut

=head1 METHODS

This package provides the following methods:

=cut

=head2 clone

  clone() (object)

The clone method returns a cloned object.

I<Since C<4.15>>

=over 4

=item clone example 1

  # given: synopsis

  my $new_user = $user->clone;

  # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')

=back

=cut

=head2 does

  does(string $name) (boolean)

The does method returns true if the object is composed of the role provided.

I<Since C<1.00>>

=over 4

=item does example 1

  # given: synopsis

  my $does = $user->does('Identity');

  # 0

=back

=cut

=head2 import

  import(any @args) (any)

The import method invokes the C<IMPORT> lifecycle hook and is invoked whenever
the L<perlfunc/use> declaration is used.

I<Since C<2.91>>

=over 4

=item import example 1

  package main;

  use User;

  # ()

=back

=cut

=head2 meta

  meta() (Venus::Meta)

The meta method returns a L<Venus::Meta> objects which describes the package's
configuration.

I<Since C<1.00>>

=over 4

=item meta example 1

  package main;

  my $user = User->new(
    fname => 'Elliot',
    lname => 'Alderson',
  );

  my $meta = $user->meta;

  # bless({...}, 'Venus::Meta')

=back

=cut

=head2 new

  new(any %args | hashref $args) (object)

The new method instantiates the class and returns a new object.

I<Since C<1.00>>

=over 4

=item new example 1

  package main;

  my $user = User->new(
    fname => 'Elliot',
    lname => 'Alderson',
  );

  # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')

=back

=over 4

=item new example 2

  package main;

  my $user = User->new({
    fname => 'Elliot',
    lname => 'Alderson',
  });

  # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')

=back

=cut

=head2 unimport

  unimport(any @args) (any)

The unimport method invokes the C<UNIMPORT> lifecycle hook and is invoked
whenever the L<perlfunc/no> declaration is used.

I<Since C<2.91>>

=over 4

=item unimport example 1

  package main;

  no User;

  # ()

=back

=cut

=head1 AUTHORS

Awncorp, C<awncorp@cpan.org>

=cut

=head1 LICENSE

Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.

This program is free software, you can redistribute it and/or modify it under
the terms of the Apache license version 2.0.

=cut