Help for this page

Select Code to Download


  1. or download this
    my $person = People
        ->new
    ...
        ->email( 'dev@null.com' )
        ->save;
    my $id = $person->get_id;
    
  2. or download this
    my $person = People->new( $id );
    print $person->first_name, ' ', $person->last_name;
    
  3. or download this
    class People {
        // Java constructors have the same name as the class
    ...
            // we can now access an object by id
        }
    }
    
  4. or download this
    sub new {
        my ($class,$id) = @_;
    ...
        %data = $class->_initialize($id) if $id;
        bless \%data, $class;
    }
    
  5. or download this
      # no!  If this is mapping to a database, you probably don't
      # want them to be able to change the id
      $person->id( $id );