The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bubblegum::Object::Universal - Common Methods for Operating on Defined Values

VERSION

version 0.45

SYNOPSIS

    use Bubblegum;

    my $thing = 0;
    $thing->instance; # bless({'data' => 0}, 'Bubblegum::Object::Instance')

DESCRIPTION

Universal methods work on variables whose data meets the criteria for being defined. It is not necessary to use this module as it is loaded automatically by the Bubblegum class.

METHODS

digest

    my $thing = '...';
    $thing->digest; # bless({'data' => '...'}, 'Bubblegum::Wrapper::Digest')

    my $data = $thing->digest->data;

The digest method blesses the subject into the wrapper class, Bubblegum::Wrapper::Digest, and returns an instance. Please see Bubblegum::Wrapper::Digest for more information.

dumper

    my $thing = '...';
    $thing->dumper; # bless({'data' => '...'}, 'Bubblegum::Wrapper::Dumper')

    my $data = $thing->dumper->data;

The dumper method blesses the subject into the wrapper class, Bubblegum::Wrapper::Dumper, and returns an instance. Please see Bubblegum::Wrapper::Dumper for more information.

encoder

    my $thing = '...';
    $thing->encoder; # bless({'data' => '...'}, 'Bubblegum::Wrapper::Encoder')

    my $data = $thing->encoder->data;

The encoder method blesses the subject into the wrapper class, Bubblegum::Wrapper::Encoder, and returns an instance. Please see Bubblegum::Wrapper::Encoder for more information.

instance

    my $thing = 0;
    $thing->instance; # bless({'data' => 0}, 'Bubblegum::Object::Instance')

    my $data = $thing->instance->data;

The instance method blesses the subject into a generic container class, Bubblegum::Object::Instance, and returns an instance. Please see Bubblegum::Object::Instance for more information.

json

    my $thing = '...';
    $thing->json; # bless({'data' => '...'}, 'Bubblegum::Wrapper::Json')

    my $data = $thing->json->data;

The json method blesses the subject into the wrapper class, Bubblegum::Wrapper::Json, and returns an instance. Please see Bubblegum::Wrapper::Json for more information.

wrapper

    my $thing = [1,0];
    $thing->wrapper('json');
    $thing->json; # bless({'data' => [1,0]}, 'Bubblegum::Wrapper::Json')

    my $json = $thing->json->encode;

The wrapper method blesses the subject into a Bubblegum wrapper, a container class, which exists as an extension to the core data type methods, and returns an instance. Please see any one of the core Bubblegum wrappers, e.g., Bubblegum::Wrapper::Digest, Bubblegum::Wrapper::Dumper, Bubblegum::Wrapper::Encoder, Bubblegum::Wrapper::Json or Bubblegum::Wrapper::Yaml.

yaml

    my $thing = '...';
    $thing->yaml; # bless({'data' => '...'}, 'Bubblegum::Wrapper::Yaml')

    my $data = $thing->yaml->data;

The yaml method blesses the subject into the wrapper class, Bubblegum::Wrapper::Yaml, and returns an instance. Please see Bubblegum::Wrapper::Yaml for more information.

ASSERTIONS

All data type objects have access to type assertions methods which can be call on to help ensure data integrity and prevent invalid usage patterns. The following is a list of standard type assertion methods whose routines map to those corresponding in the Types::Standard library.

asa_aref

    my $thing = undef;
    $thing->asa_aref;

The aref method asserts that the caller is an array reference. If the caller is not an array reference, the program will die.

asa_arrayref

    my $thing = undef;
    $thing->asa_arrayref;

The arrayref method asserts that the caller is an array reference. If the caller is not an array reference, the program will die.

asa_bool

    my $thing = undef;
    $thing->asa_bool;

The bool method asserts that the caller is a boolean value. If the caller is not a boolean value, the program will die.

asa_boolean

    my $thing = undef;
    $thing->asa_boolean;

The boolean method asserts that the caller is a boolean value. If the caller is not a boolean value, the program will die.

asa_class

    my $thing = undef;
    $thing->asa_class;

The class method asserts that the caller is a class name. If the caller is not a class name, the program will die.

asa_classname

    my $thing = undef;
    $thing->asa_classname;

The classname method asserts that the caller is a class name. If the caller is not a class name, the program will die.

asa_coderef

    my $thing = undef;
    $thing->asa_coderef;

The coderef method asserts that the caller is a code reference. If the caller is not a code reference, the program will die.

asa_cref

    my $thing = undef;
    $thing->asa_cref;

The cref method asserts that the caller is a code reference. If the caller is not a code reference, the program will die.

asa_def

    my $thing = undef;
    $thing->asa_def;

The def method asserts that the caller is a defined value. If the caller is not a defined value, the program will die.

asa_defined

    my $thing = undef;
    $thing->asa_defined;

The defined method asserts that the caller is a defined value. If the caller is not a defined value, the program will die.

asa_fh

    my $thing = undef;
    $thing->asa_fh;

The fh method asserts that the caller is a file handle. If the caller is not a file handle, the program will die.

asa_filehandle

    my $thing = undef;
    $thing->asa_filehandle;

The filehandle method asserts that the caller is a file handle. If the caller is not a file handle, the program will die.

asa_glob

    my $thing = undef;
    $thing->asa_glob;

The glob method asserts that the caller is a glob reference. If the caller is not a glob reference, the program will die.

asa_globref

    my $thing = undef;
    $thing->asa_globref;

The globref method asserts that the caller is a glob reference. If the caller is not a glob reference, the program will die.

asa_hashref

    my $thing = undef;
    $thing->asa_hashref;

The hashref method asserts that the caller is a hash reference. If the caller is not a hash reference, the program will die.

asa_href

    my $thing = undef;
    $thing->asa_href;

The href method asserts that the caller is a hash reference. If the caller is not a hash reference, the program will die.

asa_int

    my $thing = undef;
    $thing->asa_int;

The int method asserts that the caller is an integer. If the caller is not an integer, the program will die.

asa_integer

    my $thing = undef;
    $thing->asa_integer;

The integer method asserts that the caller is an integer. If the caller is not an integer, the program will die.

asa_num

    my $thing = undef;
    $thing->asa_num;

The num method asserts that the caller is a number. If the caller is not a number, the program will die.

asa_number

    my $thing = undef;
    $thing->asa_number;

The number method asserts that the caller is a number. If the caller is not a number, the program will die.

asa_obj

    my $thing = undef;
    $thing->asa_obj;

The obj method asserts that the caller is an object. If the caller is not an object, the program will die.

asa_object

    my $thing = undef;
    $thing->asa_object;

The object method asserts that the caller is an object. If the caller is not an object, the program will die.

asa_ref

    my $thing = undef;
    $thing->asa_ref;

The ref method asserts that the caller is a reference. If the caller is not a reference, the program will die.

asa_reference

    my $thing = undef;
    $thing->asa_reference;

The reference method asserts that the caller is a reference. If the caller is not a reference, the program will die.

asa_regexpref

    my $thing = undef;
    $thing->asa_regexpref;

The regexpref method asserts that the caller is a regular expression reference. If the caller is not a regular expression reference, the program will die.

asa_rref

    my $thing = undef;
    $thing->asa_rref;

The rref method asserts that the caller is a regular expression reference. If the caller is not a regular expression reference, the program will die.

asa_scalarref

    my $thing = undef;
    $thing->asa_scalarref;

The scalarref method asserts that the caller is a scalar reference. If the caller is not a scalar reference, the program will die.

asa_sref

    my $thing = undef;
    $thing->asa_sref;

The sref method asserts that the caller is a scalar reference. If the caller is not a scalar reference, the program will die.

asa_str

    my $thing = undef;
    $thing->asa_str;

The str method asserts that the caller is a string. If the caller is not a string, the program will die.

asa_string

    my $thing = undef;
    $thing->asa_string;

The string method asserts that the caller is a string. If the caller is not a string, the program will die.

asa_nil

    my $thing = undef;
    $thing->asa_nil;

The nil method asserts that the caller is an undefined value. If the caller is not an undefined value, the program will die.

asa_null

    my $thing = undef;
    $thing->asa_null;

The null method asserts that the caller is an undefined value. If the caller is not an undefined value, the program will die.

asa_undef

    my $thing = undef;
    $thing->asa_undef;

The undef method asserts that the caller is an undefined value. If the caller is not an undefined value, the program will die.

asa_undefined

    my $thing = undef;
    $thing->asa_undefined;

The undefined method asserts that the caller is an undefined value. If the caller is not an undefined value, the program will die.

asa_val

    my $thing = undef;
    $thing->asa_val;

The val method asserts that the caller is a value. If the caller is not a value, the program will die.

asa_value

    my $thing = undef;
    $thing->asa_value;

The value method asserts that the caller is a value. If the caller is not a value, the program will die.

VALIDATIONS

All data type objects have access to type checking methods which can be call on to help control the flow of operations. The following is a list of standard type checking methods whose routines map to those corresponding in the Types::Standard library.

isa_aref

    my $thing = undef;
    $thing->isa_aref;

The aref method checks that the caller is an array reference. If the caller is not an array reference, the method will return false.

isa_arrayref

    my $thing = undef;
    $thing->isa_arrayref;

The arrayref method checks that the caller is an array reference. If the caller is not an array reference, the method will return false.

isa_bool

    my $thing = undef;
    $thing->isa_bool;

The bool method checks that the caller is a boolean value. If the caller is not a boolean value, the method will return false.

isa_boolean

    my $thing = undef;
    $thing->isa_boolean;

The boolean method checks that the caller is a boolean value. If the caller is not a boolean value, the method will return false.

isa_class

    my $thing = undef;
    $thing->isa_class;

The class method checks that the caller is a class name. If the caller is not a class name, the method will return false.

isa_classname

    my $thing = undef;
    $thing->isa_classname;

The classname method checks that the caller is a class name. If the caller is not a class name, the method will return false.

isa_coderef

    my $thing = undef;
    $thing->isa_coderef;

The coderef method checks that the caller is a code reference. If the caller is not a code reference, the method will return false.

isa_cref

    my $thing = undef;
    $thing->isa_cref;

The cref method checks that the caller is a code reference. If the caller is not a code reference, the method will return false.

isa_def

    my $thing = undef;
    $thing->isa_def;

The def method checks that the caller is a defined value. If the caller is not a defined value, the method will return false.

isa_defined

    my $thing = undef;
    $thing->isa_defined;

The defined method checks that the caller is a defined value. If the caller is not a defined value, the method will return false.

isa_fh

    my $thing = undef;
    $thing->isa_fh;

The fh method checks that the caller is a file handle. If the caller is not a file handle, the method will return false.

isa_filehandle

    my $thing = undef;
    $thing->isa_filehandle;

The filehandle method checks that the caller is a file handle. If the caller is not a file handle, the method will return false.

isa_glob

    my $thing = undef;
    $thing->isa_glob;

The glob method checks that the caller is a glob reference. If the caller is not a glob reference, the method will return false.

isa_globref

    my $thing = undef;
    $thing->isa_globref;

The globref method checks that the caller is a glob reference. If the caller is not a glob reference, the method will return false.

isa_hashref

    my $thing = undef;
    $thing->isa_hashref;

The hashref method checks that the caller is a hash reference. If the caller is not a hash reference, the method will return false.

isa_href

    my $thing = undef;
    $thing->isa_href;

The href method checks that the caller is a hash reference. If the caller is not a hash reference, the method will return false.

isa_int

    my $thing = undef;
    $thing->isa_int;

The int method checks that the caller is an integer. If the caller is not an integer, the method will return false.

isa_integer

    my $thing = undef;
    $thing->isa_integer;

The integer method checks that the caller is an integer. If the caller is not an integer, the method will return false.

isa_num

    my $thing = undef;
    $thing->isa_num;

The num method checks that the caller is a number. If the caller is not a number, the method will return false.

isa_number

    my $thing = undef;
    $thing->isa_number;

The number method checks that the caller is a number. If the caller is not a number, the method will return false.

isa_obj

    my $thing = undef;
    $thing->isa_obj;

The obj method checks that the caller is an object. If the caller is not an object, the method will return false.

isa_object

    my $thing = undef;
    $thing->isa_object;

The object method checks that the caller is an object. If the caller is not an object, the method will return false.

isa_ref

    my $thing = undef;
    $thing->isa_ref;

The ref method checks that the caller is a reference. If the caller is not a reference, the method will return false.

isa_reference

    my $thing = undef;
    $thing->isa_reference;

The reference method checks that the caller is a reference. If the caller is not a reference, the method will return false.

isa_regexpref

    my $thing = undef;
    $thing->isa_regexpref;

The regexpref method checks that the caller is a regular expression reference. If the caller is not a regular expression reference, the method will return false.

isa_rref

    my $thing = undef;
    $thing->isa_rref;

The rref method checks that the caller is a regular expression reference. If the caller is not a regular expression reference, the method will return false.

isa_scalarref

    my $thing = undef;
    $thing->isa_scalarref;

The scalarref method checks that the caller is a scalar reference. If the caller is not a scalar reference, the method will return false.

isa_sref

    my $thing = undef;
    $thing->isa_sref;

The sref method checks that the caller is a scalar reference. If the caller is not a scalar reference, the method will return false.

isa_str

    my $thing = undef;
    $thing->isa_str;

The str method checks that the caller is a string. If the caller is not a string, the method will return false.

isa_string

    my $thing = undef;
    $thing->isa_string;

The string method checks that the caller is a string. If the caller is not a string, the method will return false.

isa_nil

    my $thing = undef;
    $thing->isa_nil;

The nil method checks that the caller is an undefined value. If the caller is not an undefined value, the method will return false.

isa_null

    my $thing = undef;
    $thing->isa_null;

The null method checks that the caller is an undefined value. If the caller is not an undefined value, the method will return false.

isa_undef

    my $thing = undef;
    $thing->isa_undef;

The undef method checks that the caller is an undefined value. If the caller is not an undefined value, the method will return false.

isa_undefined

    my $thing = undef;
    $thing->isa_undefined;

The undefined method checks that the caller is an undefined value. If the caller is not an undefined value, the method will return false.

isa_val

    my $thing = undef;
    $thing->isa_val;

The val method checks that the caller is a value. If the caller is not a value, the method will return false.

isa_value

    my $thing = undef;
    $thing->isa_value;

The value method checks that the caller is a value. If the caller is not a value, the method will return false.

SEE ALSO

AUTHOR

Al Newkirk <anewkirk@ana.io>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.