Hub::Data::Meta

- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- INTERNAL
- AUTHOR
- COPYRIGHT
- UPDATED

# NAME

Hub::Data::Meta - Interface for manipulating web-content meta-data

Part of the Hub Library

Top

# SYNOPSIS

        use Hub;
        my $meta = Hub::mkinst( 'Meta' );

        $new_global_id = $meta->create_id();

        $meta->define_id("user", "u%30d", 5);
        $new_user_id = $meta->create_id("user");
        die unless $new_user_id eq "u005";
        $next_user_id = $meta->create_id("user");
        die unless $new_user_id eq "u006";

        $meta->define_order("users", "ascending", "name");
        $meta->order_items("users", @users)

Top

# DESCRIPTION

Provides interfaces for manipulating internal data elements. These are defined as:

        variable name           description

        _id                     identifier which uniquely distinguishes this item
                                in its container.

        _sort                   numerical value which signifies item order within
                                its container.

        _created_by             user which has created this item

        _last_modified_by       user which has last modified this item

        _last_modified          last time this item was modified in seconds since
                                the epoch

Top

# METHODS

create_id | get_id | initHash | order_items | touch
define_id | init | new | smart_compare

create_id

  gets the next number for an id and returns the formmatted value. file storage is saved as 'meta.hf'.

  example:

        a) $meta->create_id();
        b) $meta->create_id();
        ...

        c) $meta->create_id('abc','%d',10);

  returns:

        a) 1
        b) 2
        ...

        c) 11 (presuming the id 'abc' wasn't defined, it is initialized)

define_id

  define the format and initial value for an id

  example:

        $meta->define_id('global', '%04d', 0);
        $meta->define_id('folsiz', "p%d", 100);
        $meta->define_id('bolmsk', "item%08d", 2000);

  will create ids of the form:

        0164                where the value is 164 and starts at 0
        p748                where the value is 748 and starts at 100
        item00012148        where the value is 12148 and starts at 200

get_id

  return the stored id data, or create it with default values

  example:

        $meta->get_id();
        $meta->get_id('folsiz');

  returns a hash reference to:

        the global id data
        the id data for 'folsiz'

init

       Usage: initialize

initHash

  initialize meta-data for the provided hash

new

order_items

  order the anon hashes within an array according to some hash key

       Usage: order_items( $array_ref, 'hash_key', 'sort_key' );

  1) The 'sort_key' arguement (or literally '_sort' if no arg is provided) will be assigned in the anon hash with the 0 ... n index which indicates the correct sort order.

  2) sorting will use a numeric comparison when the data of the key to sort on is purely digits.

smart_compare

  use 'cmp' or '<=>' depending on the data. missing values are pushed to the end of the list

touch

  refresh meta-data in the provided hashref.

  example:

        $meta->touch( { this => "is", a => "hashref" } );

  will:

        {
            _created_by         => guest,
            _last_modified_by   => guest,
            _created            => 1071712178,
            _last_modified      => 1071712178,
            this                => "is",
            a                   => "hashref",
        }

Top

# INTERNAL

Top

# AUTHOR

Ryan Gies

Top

# COPYRIGHT

Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.

Copyright (c) 2000-2005 Ryan Gies. All rights reserved.

Top

# UPDATED

This file created by on at

Top