| 1 | package Coat::Persistent::Object; | ||
| 2 | use Coat; | ||
| 3 | use Coat::Persistent; | ||
| 4 | use Coat::Persistent::Types; | ||
| 5 | |||
| 6 | has_p 'created_at' => ( | ||
| 7 | isa => 'Class::Date', | ||
| 8 | store_as => 'DateTime', | ||
| 9 | ); | ||
| 10 | |||
| 11 | has_p 'updated_at' => ( | ||
| 12 | isa => 'Class::Date', | ||
| 13 | store_as => 'DateTime', | ||
| 14 | ); | ||
| 15 | |||
| 16 | before 'save' => sub { | ||
| 17 | my ($self) = @_; | ||
| 18 | $self->created_at(time) unless $self->created_at; | ||
| 19 | $self->updated_at(time); | ||
| 20 | }; | ||
| 21 | |||
| 22 | 'Coat::Persistent::Object'; | ||
| 23 | __END__ |