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

This looks pretty repetitive/verbose. #9

Open
josecolella opened this issue Jan 23, 2023 · 0 comments
Open

This looks pretty repetitive/verbose. #9

josecolella opened this issue Jan 23, 2023 · 0 comments

Comments

@josecolella
Copy link
Collaborator

          This looks pretty repetitive/verbose.

Maybe could do something like:

@host ||= other_configuration.host if other_configuration.host

Might also be able to do this in a loop with some metaprogramming.

[:host, :port, :tls, :unix_socket_path, :root_cert_path].each do |attribute|
  value = instance_variable_get("@#{attribute}")
  other_value = other_configuration.send(attribute)

  instance_variable_set("@#{attribute}", value || other_value)
end

I'd also suggest moving root_cert to an attr method like I mentioned elsewhere:

def root_cert
  @root_cert ||= File.read(@root_cert_path)
end

Originally posted by @technicalpickles in #8 (comment)

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

No branches or pull requests

1 participant