class Dslimple::Query
Attributes
operation[R]
params[R]
target[R]
zone[R]
Public Class Methods
new(operation, target, zone, params = {})
click to toggle source
# File lib/dslimple/query.rb, line 6 def initialize(operation, target, zone, params = {}) @operation = operation @target = target @zone = zone @params = params end
Public Instance Methods
execute(api_client, account)
click to toggle source
# File lib/dslimple/query.rb, line 37 def execute(api_client, account) __send__("execute_#{target}", api_client, account) end
execute_record(api_client, account_id)
click to toggle source
# File lib/dslimple/query.rb, line 52 def execute_record(api_client, account_id) case operation when :addition api_client.zones.create_zone_record(account_id, zone, params) when :modification api_client.zones.update_zone_record(account_id, zone, params[:id], params) when :deletion api_client.zones.delete_zone_record(account_id, zone, params[:id]) end end
execute_zone(api_client, account_id)
click to toggle source
# File lib/dslimple/query.rb, line 41 def execute_zone(api_client, account_id) case operation when :addition # TODO: Support registration # api_client.registrar.register_zone(account_id, zone, registrant_id: account.id, auto_renew: true) when :deletion # TODO: Support deletion # api_client.zones.delete_zone(account_id, zone) end end
record_options()
click to toggle source
# File lib/dslimple/query.rb, line 29 def record_options options = [] params.each_pair do |k, v| options << "#{k}: #{v}" if %i(ttl priority regions).include?(k) && v end options end
to_s()
click to toggle source
# File lib/dslimple/query.rb, line 21 def to_s if target == :zone zone.to_s else %(#{params[:type].to_s.rjust(5)} #{params[:name].to_s.rjust(10)}.#{zone.to_s} (#{record_options.join(', ')}) "#{params[:content]}") end end