Naoto Ishikawa > MongoDBx-Tiny-0.03 > MongoDBx::Tiny::Attributes

Download:
MongoDBx-Tiny-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source   Latest Release: MongoDBx-Tiny-0.04

NAME ^

MongoDBx::Tiny::Attributes - offering field attributes

SYNOPSIS ^

  package My::Data::Foo;

  use MongoDBx::Tiny::Document;

  COLLECTION_NAME 'foo';

  ESSENTIAL q/code/;
  FIELD 'code', INT, LENGTH(10), DEFAULT('0'), REQUIRED;
  FIELD 'name', STR, LENGTH(30), DEFAULT('noname');

  # you can also define customized one.
  
  FIELD 'some', &SOME_ATTRIBUTE;
  sub SOME_ATTRIBUTE {
        name     => 'SOME_ATTRIBUTE',
        callback => sub {
            my $target = shift;
            return MongoDBx::Tiny::Attributes::OK;
        },
  }

callback arguments

  callback = sub {
       my $target = shift;
       my $tiny   = shift;
       my $opt    = shift; # state => 'insert|update'
       return FAIL, { message => 'error' };
       return OK,   { target => $target  }; # override target if you want
  }

ATTRIBUTES ^

LENGTH

  LENGTH(255)

INT

UINT

HEX

STR

ENUM

  ENUM('on','off')

REF

HASH

ARRAY

DATETIME

TIMESTAMP

REGEX

  REGEX('\d+')

NOT_NULL

OID

DEFAULT

  DEFAULT("foo")
  DEFAULT([])

REQUIRED

NOW

DEFAULT(NOW('Asia/Tokyo')

READ_ONLY

AUTHOR ^

Naoto ISHIKAWA, <toona at seesaa.co.jp>

Kouji Tominaga, <tominaga at seesaa.co.jp>

LICENSE AND COPYRIGHT ^

Copyright 2013 Naoto ISHIKAWA.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: