internetee/registry

View on GitHub
app/interactions/whois/update_record.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module Whois
  class UpdateRecord < ActiveInteraction::Base
    hash :record do
      string :klass
      integer :id
      string :type
    end

    def execute
      data = record['klass'].constantize.find_by(id: record['id'])
      send "update_#{record['type']}", data
    end

    def update_domain(domain)
      domain.whois_record ? domain.whois_record.save : domain.create_whois_record
    end

    def update_reserved(record)
      record.generate_data
    end

    def update_blocked(record)
      update_reserved(record)
    end

    def update_disputed(record)
      update_reserved(record)
    end

    def update_zone(record)
      update_reserved(record)
    end
  end
end