use Data::Perl::Collection::Set;
use Scalar::Util qw(weaken refaddr);
+has _inflator => (
+ is => 'ro',
+ handles => {
+ _inflate => 'inflate',
+ _deflate => 'deflate',
+ _merge => 'merge',
+ _refresh => 'refresh',
+ _deflate_spec => 'deflate_spec',
+ _merge_spec => 'merge_spec',
+ },
+ default => method {
+ require DBIx::Data::Store::SimpleInflator;
+ my $args = {};
+ $args->{class} = $self->_class if $self->_has_class;
+ DBIx::Data::Store::SimpleInflator->new($args)
+ },
+);
+
has _store => (is => 'ro', required => 1, init_arg => 'store');
has _class => (is => 'ro', predicate => '_has_class', init_arg => 'class');
return
}
-## thunking between the store representation and the set representation
-#
-# _inflate is raw data -> final repr
-# _deflate is final repr -> raw data
-# _merge takes final repr + raw data and updates the repr
-# (this is used for pk-generated values and later lazy loading)
-#
-# _deflate_spec is attributes of final repr -> raw data
-# _merge_spec is final repr + extra attributes and update repr
-
-method _inflate ($raw) {
- bless($raw, $self->_class) if $self->_has_class;
- $raw
-}
-
-method _deflate ($obj) {
- +{ %$obj }
-}
-
-method _merge ($obj, $raw) {
- @{$obj}{keys %$raw} = values %$raw;
- $obj
-}
-
-method _refresh ($obj, $raw) {
- # if $obj has been changed but not flushed we'd destroy data doing
- # a blind merge - but if $obj has change tracking of some sort then
- # we -could- do something safely, so this method exists to be mangled
- # by subclasses
- $obj
-}
-
-method _deflate_spec ($spec) {
- $spec
-}
-
-method _merge_spec ($obj, $spec) {
- @{$obj}{keys %$spec} = values %$spec;
- $obj
-}
## methods to get ids
--- /dev/null
+package DBIx::Data::Store::SimpleInflator;
+
+## thunking between the store representation and the set representation
+#
+# _inflate is raw data -> final repr
+# _deflate is final repr -> raw data
+# _merge takes final repr + raw data and updates the repr
+# (this is used for pk-generated values and later lazy loading)
+#
+# _deflate_spec is attributes of final repr -> raw data
+# _merge_spec is final repr + extra attributes and update repr
+
+use Moose;
+use Method::Signatures::Simple;
+
+has class => (is => 'ro', predicate => '_has_class' );
+
+method inflate($raw) {
+ bless($raw, $self->class) if $self->_has_class;
+ $raw
+}
+
+method deflate($obj) {
+ +{ %$obj }
+}
+
+method merge ($obj, $raw) {
+ @{$obj}{keys %$raw} = values %$raw;
+ $obj
+}
+
+method refresh ($obj, $raw) {
+ # if $obj has been changed but not flushed we'd destroy data doing
+ # a blind merge - but if $obj has change tracking of some sort then
+ # we -could- do something safely, so this method exists to be mangled
+ # by subclasses
+ $obj
+}
+
+method deflate_spec ($spec) {
+ $spec
+}
+
+method merge_spec ($obj, $spec) {
+ @{$obj}{keys %$spec} = values %$spec;
+ $obj
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;