1 package DBIx::Data::Store::SimpleInflator;
3 ## thunking between the store representation and the set representation
5 # _inflate is raw data -> final repr
6 # _deflate is final repr -> raw data
7 # _merge takes final repr + raw data and updates the repr
8 # (this is used for pk-generated values and later lazy loading)
10 # _deflate_spec is attributes of final repr -> raw data
11 # _merge_spec is final repr + extra attributes and update repr
14 use Method::Signatures::Simple;
16 has class => (is => 'ro', predicate => '_has_class' );
18 method inflate($raw) {
19 bless($raw, $self->class) if $self->_has_class;
23 method deflate($obj) {
27 method merge ($obj, $raw) {
28 @{$obj}{keys %$raw} = values %$raw;
32 method refresh ($obj, $raw) {
33 # if $obj has been changed but not flushed we'd destroy data doing
34 # a blind merge - but if $obj has change tracking of some sort then
35 # we -could- do something safely, so this method exists to be mangled
40 method deflate_spec ($spec) {
44 method merge_spec ($obj, $spec) {
45 @{$obj}{keys %$spec} = values %$spec;
49 __PACKAGE__->meta->make_immutable;