Class: EPP::Request
- Inherits:
-
Object
- Object
- EPP::Request
- Defined in:
- lib/epp-client/request.rb
Overview
An EPP XML Request
Direct Known Subclasses
Instance Method Summary collapse
-
#command ⇒ String
Name of the receivers command.
-
#initialize(command, *args, &block) ⇒ Request
constructor
Create new instance of EPP::Request.
- #inspect ⇒ Object
-
#to_s(opts = {}) ⇒ Object
Convert the receiver to a string.
-
#to_xml ⇒ XML::Document
Receiver in XML form.
Constructor Details
#initialize(command, payload, transaction_id) ⇒ Request #initialize(command, transaction_id) {|xml| ... } ⇒ Request
Create new instance of EPP::Request.
16 17 18 19 20 21 22 23 24 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 |
# File 'lib/epp-client/request.rb', line 16 def initialize(command, *args, &block) @command = XML::Node.new(command) cmd = XML::Node.new('command') cmd << @command xml.root << cmd if block_given? tid, _ = args case block.arity when 1 block.call(@command) else @command << block.call end else payload, tid = args unless payload.nil? @command << case payload.class when XML::Node payload when XML::Document xml.import(payload.root) else doc = XML::Parser.string(payload.to_s).parse xml.import(doc.root) end end end unless command == 'logout' cmd << XML::Node.new('clTRID', tid || 'ABC-12345') end end |
Instance Method Details
#command ⇒ String
Name of the receivers command
53 54 55 |
# File 'lib/epp-client/request.rb', line 53 def command @command.name end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/epp-client/request.rb', line 71 def inspect xml.inspect end |
#to_s(opts = {}) ⇒ Object
Convert the receiver to a string
66 67 68 |
# File 'lib/epp-client/request.rb', line 66 def to_s(opts = {}) xml.to_s({:indent => false}.merge(opts)) end |
#to_xml ⇒ XML::Document
Receiver in XML form
59 60 61 |
# File 'lib/epp-client/request.rb', line 59 def to_xml xml end |