diff options
author | Tiago Freire <code.tiago.frire@locaweb.com.br> | 2016-09-15 15:17:53 -0300 |
---|---|---|
committer | Tiago Freire <code.tiago.frire@locaweb.com.br> | 2016-09-15 15:17:53 -0300 |
commit | ee79940458e0ded34fd23b30de927ae3e3426320 (patch) | |
tree | 438663bb0a3397e8ff79d3c529cea0c22fcb185b | |
parent | adjust models and manager (diff) |
Fix RRSet find
-rw-r--r-- | lib/powerdnsex/models/resource_record_set.ex | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/powerdnsex/models/resource_record_set.ex b/lib/powerdnsex/models/resource_record_set.ex index 89973a8..4955cc8 100644 --- a/lib/powerdnsex/models/resource_record_set.ex +++ b/lib/powerdnsex/models/resource_record_set.ex @@ -13,8 +13,6 @@ defmodule PowerDNSex.Models.ResourceRecordSet do end def as_body(%__MODULE__{} = rrset) do - IO.puts "RRSet: #{inspect rrset}" - %{ rrsets: [ %{ name: rrset.name, @@ -30,7 +28,8 @@ defmodule PowerDNSex.Models.ResourceRecordSet do def find(rrsets, %{} = attrs) when is_list(rrsets) do Enum.find(rrsets, fn(rrset)-> Enum.all?(attrs, fn({attr, attr_value})-> - if Enum.member?(Map.keys(%__MODULE__{}), attr) do + attr_atom = if is_binary(attr), do: String.to_atom(attr), else: attr + if Enum.member?(Map.keys(%__MODULE__{}), attr_atom) do equal_attr?(attr, attr_value, rrset) else Record.find(rrset.records, %{attr => attr_value}) @@ -58,6 +57,7 @@ defmodule PowerDNSex.Models.ResourceRecordSet do end defp equal_attr?(attr, attr_value, rrset) do - Map.get(rrset, attr) == attr_value + attr_atom = if is_binary(attr), do: String.to_atom(attr), else: attr + Map.get(rrset, attr_atom) == attr_value end end |