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

Update dns #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
:minor: 5
:patch: 3
:patch: 4
:major: 0
:build:
2 changes: 1 addition & 1 deletion lib/dreamy/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def users(passwords=false)
def dns
doc = request("dns-list_records")
api_error?(doc)
(doc/:data).inject([]) { |records, dns| records << Dns.new_from_xml(dns); records }
(doc/:data).inject([]) { |records, dns| records << Dns.new_from_xml(dns,self); records }
end

def dns_add(record,type,value)
Expand Down
13 changes: 11 additions & 2 deletions lib/dreamy/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module Dreamy
class Dns
include EasyClassMaker

attributes :account_id, :comment, :editable, :record, :type, :value, :zone
attributes :account_id, :comment, :editable, :record, :type, :value, :zone, :account

def self.new_from_xml(xml)
def self.new_from_xml(xml, account=nil)
d = new
d.account_id = (xml).at('account_id').innerHTML.to_i
d.comment = (xml).at('comment').innerHTML
Expand All @@ -13,7 +13,16 @@ def self.new_from_xml(xml)
d.type = (xml).at('type').innerHTML
d.value = (xml).at('value').innerHTML
d.zone = (xml).at('zone').innerHTML
d.account = account
d
end

def update new_type, new_value
account.dns_remove record, type, value
account.dns_add record, new_type, new_value

self
end

end
end