Browse files

Default device name to app name

  • Loading branch information...
1 parent 4abd8f0 commit 7c935536dc359026768e659173b97c186e073967 @tsee committed Mar 27, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/ZMQ/Declare/
@@ -41,8 +41,8 @@ has '_runtime_context' => (
sub device {
my ($self, $name) = @_;
- Carp::croak("Need device name")
- if not defined $name;
+ # For convenience: default to using application name for device if none provided
+ $name = $self->name if not defined $name;
my $app_spec = $self->_app_tree_ref;
my $dev_spec = $app_spec->{devices}{$name};
@@ -139,6 +139,11 @@ Note that creating a C<ZMQ::Declare::Device> object does B<not>
create any 0MQ contexts, sockets, or connections yet, you need
to call C<make_runtime()> or C<run()> on the device for that.
+As a convenience, the device name defaults to the application name
+if none is provided. This is to cater to the cases of simple
+applications that have only one device that needs not have a
+different name than the application itself.
=head2 device_names
Returns a list (not a reference) of device names that are known to

0 comments on commit 7c93553

Please sign in to comment.