Provided by: librose-db-object-perl_0.815-1_all
NAME
Rose::DB::Object::MakeMethods::BigNum - Create object methods for arbitrary-precision numeric attributes for Rose::DB::Object-derived objects.
SYNOPSIS
package MyDBObject; our @ISA = qw(Rose::DB::Object); use Rose::DB::Object::MakeMethods::BigNum ( bigint => [ count => { with_init => 1, min => 0, }, # Important: specify very large integer values as strings tally => { default => '9223372036854775800' }, ], ); sub init_count { 12345 } ... $obj = MyDBObject->new(...); print $obj->count; # 12345 print $obj->tally; # 9223372036854775800
DESCRIPTION
Rose::DB::Object::MakeMethods::BigNum is a method maker that inherits from Rose::Object::MakeMethods. See the Rose::Object::MakeMethods documentation to learn about the interface. The method types provided by this module are described below. All method types defined by this module are designed to work with objects that are subclasses of (or otherwise conform to the interface of) Rose::DB::Object. See the Rose::DB::Object documentation for more details.
METHODS TYPES
bigint Create get/set methods for big integer attributes. Values are stored internally and returned as Math::BigInt objects. When specifying very large integer values, use strings to be safe. (See an example in the synopsis above.) Options check_in ARRAYREF A reference to an array of valid values. When setting the attribute, if the new value is not equal to one of the valid values, a fatal error will occur. default VALUE Determines the default value of the attribute. hash_key NAME The key inside the hash-based object to use for the storage of this attribute. Defaults to the name of the method. init_method NAME The name of the method to call when initializing the value of an undefined attribute. Defaults to the method name with the prefix "init_" added. This option implies "with_init". interface NAME Choose the interface. The default is "get_set". max INT Get or set the maximum value this attribute is allowed to have. min INT Get or set the minimum value this attribute is allowed to have. with_init BOOL Modifies the behavior of the "get_set" and "get" interfaces. If the attribute is undefined, the method specified by the "init_method" option is called and the attribute is set to the return value of that method. Interfaces Interfaces get_set Creates a get/set method for a big integer object attribute. When called with an argument, the value of the attribute is set. The current value of the attribute is returned. get Creates an accessor method for a big integer object attribute that returns the current value of the attribute. set Creates a mutator method for a big integer object attribute. When called with an argument, the value of the attribute is set. If called with no arguments, a fatal error will occur. Example: package MyDBObject; our @ISA = qw(Rose::DB::Object); use Rose::DB::Object::MakeMethods::BigNum ( bigint => [ count => { with_init => 1, min => 0, }, # Important: specify very large integer values as strings tally => { default => '9223372036854775800' }, ], ); sub init_count { 12345 } ... $obj = MyDBObject->new(...); print $obj->count; # 12345 print $obj->tally; # 9223372036854775800 $obj->count(-1); # Fatal error: minimum value is 0
AUTHOR
John C. Siracusa (siracusa@gmail.com)
LICENSE
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.