Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Default device name to app name

  • Loading branch information...
commit 7c935536dc359026768e659173b97c186e073967 1 parent 4abd8f0
Steffen Müller authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/ZMQ/Declare/Application.pm
9 lib/ZMQ/Declare/Application.pm
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.