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
27 28 29 |
# File 'lib/domrobot/types/record.rb', line 27 def delete Domrobot.nameserver.deleteRecord({"id" => self.id}) end |
#save ⇒ Object
20 21 22 23 |
# File 'lib/domrobot/types/record.rb', line 20 def save puts self.to_h Domrobot.nameserver.createRecord Util.stringify_keys(self.to_h).reject{|k,v|k=="id"} end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/domrobot/types/record.rb', line 30 def to_h @table end |
#update ⇒ Object
24 25 26 |
# File 'lib/domrobot/types/record.rb', line 24 def update Domrobot.nameserver.updateRecord Util.stringify_keys(self.to_h).reject{|k,v|%w{type domain}.include? k} end |