mikejdorm / sftp_ex

MIT License
25 stars 23 forks source link

SftpEx.get_type + Access error #22

Open Jbalcek opened 5 years ago

Jbalcek commented 5 years ago

Hi Mike,

First: Congrats for the good SFTP Elixir job !

1) SftpEx.get_type doesn't return {:ok, type} when it succeed, as stated in the documentation, but only type.

2) You should add the Access behaviour to Sftp.Connection : @behaviour Access

and

 # Access callbacks the easy way
  def fetch(term, key) do
    term
    |> Map.from_struct()
    |> Map.fetch(key)
  end

  def get(term, key, default) do
    term
    |> Map.from_struct()
    |> Map.get(key, default)
  end

  def get_and_update(data, key, function) do
    data
    |> Map.from_struct()
    |> Map.get_and_update(key, function)
  end

  def pop(data, key) do
    data
    |> Map.from_struct()
    |> Map.pop(key)
  end

to avoid access errors...

Best regards.