1 package App::Clifton::Set;
3 use Scalar::Util qw(blessed);
6 requires '_set_of_class';
9 has _set => (is => 'ro', default => sub { {} });
12 my ($self, $spec) = @_;
13 $self->_set->{$self->_spec_to_key($spec)} = $self->_spec_to_object($spec);
17 my ($self, $spec) = @_;
18 $self->_set->{$self->_spec_to_key($spec)};
22 my ($self, $spec) = @_;
23 delete $self->_set->{$self->_spec_to_key($spec)};
28 my $set = $self->_set;
29 map $set->{$_}, sort keys %$set;
33 my ($self, $spec) = @_;
34 if (blessed($spec) && $spec->isa($self->_set_of_class)) {
37 $self->_new_member($self->_spec_to_constructor_args($spec));
42 my ($self, $args) = @_;
43 $self->_set_of_class->new($args);
46 sub _spec_to_constructor_args {
47 my ($self, $spec) = @_;
52 my ($self, $spec) = @_;
53 my $key = $self->_set_over;
54 die "key ${key} is required" unless $spec->{$key};