Skip to content
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

Merged
merged 3 commits into from
Mar 7, 2014

Conversation

vmoravec
Copy link
Contributor

@vmoravec vmoravec commented Mar 6, 2014

The reasoning behind this is:
If you can't handle any nil at the place of calling, use the finder with exclamation mark; SystemdSocketNotFound or SystemdServiceNotFound exception will be raised.

 socket = Yast::SystemdSocket.find!('IcanHasCheez')
# => Yast::SystemdSocketNotFound: Socket unit 'IcanHasCheez' not found

def find! service_name, properties={}
service = find(service_name, properties)
return service if service
raise SystemdServiceNotFound, "Service unit '#{service_name}' not found"
Copy link
Member

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"

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Contributor Author

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.

@jreidinger
Copy link
Member

just small style nitpick, LGTM

vmoravec pushed a commit that referenced this pull request Mar 7, 2014
Add .find! methods to system unit modules
@vmoravec vmoravec merged commit c09dbbf into yast:master Mar 7, 2014
@vmoravec vmoravec deleted the add-exceptions-systemd branch March 7, 2014 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants