summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Freire <code.tiago.frire@locaweb.com.br>2016-09-15 15:17:53 -0300
committerTiago Freire <code.tiago.frire@locaweb.com.br>2016-09-15 15:17:53 -0300
commitee79940458e0ded34fd23b30de927ae3e3426320 (patch)
tree438663bb0a3397e8ff79d3c529cea0c22fcb185b
parentadjust models and manager (diff)
Fix RRSet find
-rw-r--r--lib/powerdnsex/models/resource_record_set.ex8
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