Skip to content

This looks pretty repetitive/verbose. #9

@josecolella

Description

@josecolella
          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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions