-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .find! methods to system unit modules #187
Conversation
def find! service_name, properties={} | ||
service = find(service_name, properties) | ||
return service if service | ||
raise SystemdServiceNotFound, "Service unit '#{service_name}' not found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, you can use also one-liner with ||
or or
find(service_name, properties) or raise SystemdServiceNotFound, "Service unit '#{service_name}' not found"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but its 107 characters, you would have to split it into 2 lines to make it fit into a common editor or github window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, just nitpick. In fact I expect that you have own constructor for exception and pass only service_name.
then it will look like
find(service_name, properties) or raise(SystemdServiceNotFound, service_name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks, I will adapt the exception classes.
just small style nitpick, LGTM |
Add .find! methods to system unit modules
The reasoning behind this is:
If you can't handle any
nil
at the place of calling, use the finder with exclamation mark;SystemdSocketNotFound
orSystemdServiceNotFound
exception will be raised.