Geoffrey

 view release on metacpan or  search on metacpan

lib/Geoffrey/Action/Constraint/Index.pm  view on Meta::CPAN

package Geoffrey::Action::Constraint::Index;

use utf8;
use 5.016;
use strict;
use warnings;

use parent 'Geoffrey::Role::Action';

$Geoffrey::Action::Constraint::Index::VERSION = '0.000206';

sub add {
    my ( $self, $hr_params ) = @_;
    return $self->do( $self->converter->index->add($hr_params) );
}

sub alter {
    my ( $self, $hr_params ) = @_;
    return [ $self->drop($hr_params), $self->add($hr_params) ];
}

sub drop {
    my ( $self, $hr_params ) = @_;
    require Ref::Util;
    my $s_name = Ref::Util::is_hashref($hr_params) ? $hr_params->{name} : undef;
    if ( !$s_name ) {
        require Geoffrey::Exception::RequiredValue;
        Geoffrey::Exception::RequiredValue::throw_index_name('to drop');
    }
    return $self->do( $self->converter->index->drop($s_name) );
}

sub list_from_schema {
    my ( $self, $schema ) = @_;
    my $converter = $self->converter;
    return $converter->index_information( $self->do_arrayref( $converter->index->list($schema) ) );

}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Geoffrey::Action::Constraint::Index - Action handler for indexes

=head1 VERSION

Version 0.000206

=head1 DESCRIPTION

=head1 SYNOPSIS

=head1 SUBROUTINES/METHODS

=head2 add
 
If it's supported new index will be created.

=head2 alter

Not needed!

=head2 drop
    
Not needed!

=head2 list_from_schema 
    
Not needed!

=head1 DIAGNOSTICS

=head1 CONFIGURATION AND ENVIRONMENT

=head1 DEPENDENCIES

=head1 INCOMPATIBILITIES



( run in 0.707 second using v1.01-cache-2.11-cpan-39bf76dae61 )