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)};
23 my $set = $self->_set;
24 map $set->{$_}, sort keys %$set;
28 my ($self, $spec) = @_;
29 if (blessed($spec) && $spec->isa($self->_set_of_class)) {
32 $self->_new_member($self->_spec_to_constructor_args($spec));
37 my ($self, $args) = @_;
38 $self->_set_of_class->new($args);
41 sub _spec_to_constructor_args {
42 my ($self, $spec) = @_;
47 my ($self, $spec) = @_;
48 my $key = $self->_set_over;
49 die "key ${key} is required" unless $spec->{$key};