Class: Domrobot::Record
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Domrobot::Record
- Defined in:
- lib/domrobot/types/record.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by(params = {}) ⇒ Object
16 17 18 |
# File 'lib/domrobot/types/record.rb', line 16 def find_by params={} where(params).first end |
.where(params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/domrobot/types/record.rb', line 6 def where params={} return unless params[:domain] Domrobot.nameserver.info(domain: params[:domain])["resData"]["record"].select do |record_data| params.reject{|k,v|k==:domain}.collect do |property,value| record_data[property.to_s].match(value) != nil end.reduce(:&) end.collect do |record| self.new record.merge(domain:params[:domain]) end end |
Instance Method Details
#delete ⇒ Object
26 27 28 |
# File 'lib/domrobot/types/record.rb', line 26 def delete Domrobot.nameserver.deleteRecord({"id":self.id}) end |
#request ⇒ Object
29 30 31 |
# File 'lib/domrobot/types/record.rb', line 29 def request self.to_h.map{|k,v| ["#{k}",v] }.to_h end |
#save ⇒ Object
20 21 22 |
# File 'lib/domrobot/types/record.rb', line 20 def save Domrobot.nameserver.createRecord request.reject{|k,v|k=="id"} end |
#update ⇒ Object
23 24 25 |
# File 'lib/domrobot/types/record.rb', line 23 def update Domrobot.nameserver.updateRecord request.reject{|k,v|%w{type domain}.include? k} end |