Class: EPP::Host::Update

Inherits:
Command show all
Defined in:
lib/epp-client/host/update.rb

Constant Summary collapse

ADD_REM_ORDER =
[:addr, :status]
CHG_ORDER =
[:name]

Instance Attribute Summary

Attributes inherited from Command

#namespaces

Instance Method Summary collapse

Methods inherited from Command

#set_namespaces

Methods included from XMLHelpers

#as_xml, #epp_namespace, #epp_node, #xml_document, #xml_namespace, #xml_node

Constructor Details

#initialize(name, options = {}) ⇒ Update

Returns a new instance of Update.

Parameters:

  • [Hash] (Hash)

    a customizable set of options



10
11
12
13
14
15
16
17
18
19
# File 'lib/epp-client/host/update.rb', line 10

def initialize(name, options = {})
  @name = name
  @add  = options.delete(:add) || {}
  @rem  = options.delete(:rem) || {}
  @chg  = options.delete(:chg) || {}

  @add.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
  @rem.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
  @chg.delete_if { |k,_| !CHG_ORDER.include?(k) }
end

Instance Method Details

#nameObject



21
22
23
# File 'lib/epp-client/host/update.rb', line 21

def name
  'update'
end

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/epp-client/host/update.rb', line 25

def to_xml
  node = super
  node << host_node('name', @name)

  unless @add.empty?
    node << add = host_node('add')
    add_rem_to_xml(add, @add)
  end

  unless @rem.empty?
    node << rem = host_node('rem')
    add_rem_to_xml(rem, @rem)
  end

  unless @chg.empty?
    node << chg = host_node('chg')
    CHG_ORDER.each do |key|
      value = @chg[key]
      next if value.nil?
      
      case key
      when :name
        chg << host_node('name', value)
      end
    end
  end
  
  node
end