Class: EPP::Contact::Update
- Defined in:
- lib/epp-client/contact/update.rb
Constant Summary collapse
- ADD_REM_ORDER =
[:status]
- CHG_ORDER =
[:postal_info, :voice, :fax, :email, :auth_info, :disclose]
Constants inherited from Command
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#initialize(id, options = {}) ⇒ Update
constructor
A new instance of Update.
- #name ⇒ Object
- #to_xml ⇒ Object
Methods inherited from Command
Methods included from XMLHelpers
#as_xml, #epp_namespace, #epp_node, #xml_document, #xml_namespace, #xml_node
Constructor Details
#initialize(id, options = {}) ⇒ Update
Returns a new instance of Update.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/epp-client/contact/update.rb', line 10 def initialize(id, = {}) @id = id @add = .delete(:add) || {} @rem = .delete(:rem) || {} @chg = .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
#name ⇒ Object
21 22 23 |
# File 'lib/epp-client/contact/update.rb', line 21 def name 'update' end |
#to_xml ⇒ Object
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 54 55 56 57 58 59 |
# File 'lib/epp-client/contact/update.rb', line 25 def to_xml node = super node << contact_node('id', @id) unless @add.empty? node << add = contact_node('add') add_rem_to_xml(add, @add) end unless @rem.empty? node << rem = contact_node('rem') add_rem_to_xml(rem, @rem) end unless @chg.empty? node << chg = contact_node('chg') CHG_ORDER.each do |key| value = @chg[key] next if value.nil? || value.empty? case key when :postal_info chg << postal_info_to_xml(value) when :auth_info chg << auth_info_to_xml(value) when :disclose chg << disclose_to_xml(value) when :voice, :fax, :email chg << contact_node(key.to_s, value) end end end node end |