Author: Nathan Goodman

# NAME

Class::AutoDB::Collection - Compare two collection definitions and maintain differences

# SYNOPSIS

This is a helper class for Class::AutoDB::Registry to to process differences between in-memory and saved registries

    use Class::AutoDB::CollectionDiff;
    use Class::AutoDB::Collection;
    my $diff=new Class::AutoDB::CollectionDiff
      (-baseline=>$saved, -change=>$in_memory);
    if ($diff->is_sub) {               # is new collection subset of saved one?
      $registry=$saved_registry;       # if so, use saved one
    } elsif  ($diff->is_different) {   # else get changes
      my %new_keys=$diff->new_keys;    #
      my @expanded_collections=$diff->expanded_collections;
    } else {
      die “New collection inconsistent with old”;
    }

# DESCRIPTION

This class compares two collection definitions and records their differences. The first collection is considered the baseline, and differences are reported relative to it. This class does not talk to the database.

# BUGS and WISH-LIST

Name | Description | Priority/When
--- | --- | ---

# METHODS and FUNCTIONS - Initialization

Title | new
Usage |
    my $diff=new Class::AutoDB::CollectionDiff
      (-baseline=>$saved, -change=>$in_memory);
Function | Constructor.
Args | -baseline | Class::AutoDB::Collection object
-other | Class::AutoDB::Collection object
Returns | CollectionDiff object

# METHODS and FUNCTIONS – Simple Attributes

These are methods for getting and setting the values of simple attributes. Methods have the same name as the attribute. Some of these should be read-only (more precisely, should only be written by code internal to the object), but this is not enforced.

To get the value of attribute xxx, just say

$xxx=$object->xxx;

To set an attribute, say

$object->xxx($new_value);

To clear it, say

$object->xxx(undef);

# METHODS and FUNCTIONS

Title |
    new_keys
Usage | my $new_keys=$diff->new_keys;
Function | Return keys=>type pairs for keys present in new collection, but not baseline
Args |
    none
Returns | # HASH ref

Title |
    inconsistent_keys
Usage | my $key_errors=$diff->inconsistent_keys
Function | Return keys that are present in both collections with different types. For each such key, both the old and new types are reported
Args |
    none
Returns | HASH ref of key=>[baseline_type, other_type] pairs

Title |
    is_consistent
Usage | my $bool=$diff->is_consistent
Function | Check if collection are consistent
Args |
    none
Returns | true/false value

Title |
    is_inconsistent
Usage | my $bool=$diff->is_inconsistent
Function | Check if collection are inconsistent
Args |
    none
Returns | true/false value

Title |
    is_equivalent
Usage | my $bool=$diff->is_equivalent
Function | Check if collection are equivalent
Args |
    none
Returns | true/false value

Title |
    is_different
Usage | my $bool=$diff->is_different
Function | Check if collection are different (not equivalent)
Args |
    none
Returns | true/false value

Title |
    is_sub
Usage | my $bool=$diff->is_sub
Function | Check if new collection is subset of baseline. Note: equivalent is considered subset
Args |
    none
Returns | true/false value

Title |
    is_super
Usage | my $bool=$diff->is_sub
Function | Check if new collection is superset of baseline. Note: equivalent is considered superset
Args |
    none
Returns | true/false value

Title |
    is_expanded
Usage | my $bool=$diff->is_expanded
Function | Check if new collection has new keys relative to baseline
Args |
    none
Returns | true/false value

#