Class: NFS::SUNRPC::Procedure
- Inherits:
-
Object
- Object
- NFS::SUNRPC::Procedure
- Defined in:
- lib/nfs/sunrpc/procedure.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #call(arg, cred, verf) ⇒ Object
- #decode(value) ⇒ Object
- #dup ⇒ Object
- #encode(arg) ⇒ Object
-
#initialize(number, returntype, argtype, &block) ⇒ Procedure
constructor
A new instance of Procedure.
- #on_call(&block) ⇒ Object
Constructor Details
#initialize(number, returntype, argtype, &block) ⇒ Procedure
Returns a new instance of Procedure.
6 7 8 9 10 |
# File 'lib/nfs/sunrpc/procedure.rb', line 6 def initialize(number, returntype, argtype, &block) @number = number @returntype, @argtype = returntype, argtype @block = block end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
4 5 6 |
# File 'lib/nfs/sunrpc/procedure.rb', line 4 def number @number end |
Instance Method Details
#call(arg, cred, verf) ⇒ Object
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/nfs/sunrpc/procedure.rb', line 28 def call(arg, cred, verf) begin arg_object = @argtype.decode(arg) rescue raise GarbageArguments end # Undefined procedures are also unavailable, even if the XDR says it's # there. Define your procedures and this won't happen. if @block.nil? raise ProcedureUnavailable end result_object = @block.call(arg_object, cred, verf) result = nil begin result = @returntype.encode(result_object) rescue => e ::NFS.logger.error(e.) ::NFS.logger.error(e.backtrace.join("\n")) raise IgnoreRequest end result end |
#decode(value) ⇒ Object
24 25 26 |
# File 'lib/nfs/sunrpc/procedure.rb', line 24 def decode(value) @returntype.decode(value) end |
#dup ⇒ Object
12 13 14 |
# File 'lib/nfs/sunrpc/procedure.rb', line 12 def dup Procedure.new(@number, @returntype, @argtype, &@block) end |
#encode(arg) ⇒ Object
20 21 22 |
# File 'lib/nfs/sunrpc/procedure.rb', line 20 def encode(arg) @argtype.encode(arg) end |
#on_call(&block) ⇒ Object
16 17 18 |
# File 'lib/nfs/sunrpc/procedure.rb', line 16 def on_call(&block) @block = block end |