Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/net/netconf/rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ module Builder
# autogenerate an <rpc>, converting underscores (_)
# to hyphens (-) along the way ...

def self.method_missing(method, params = nil, attrs = nil)
def self.method_missing(method, params = nil, attrs = nil, &block)
rpc_name = method.to_s.tr('_', '-').to_sym

# build the XML starting at <rpc>, envelope the <method>
# toplevel element, then create name/value elements for each
# of the additional params. An element without a value should
# simply be set to true
rpc_nx = if params
rpc_nx = if params || block
Nokogiri::XML::Builder.new do |xml|
xml.rpc do
xml.send(rpc_name) do
params.each do |k, v|
sym = k.to_s.tr('_', '-').to_sym
xml.send(sym, v == true ? nil : v)
end
end if params
block.call(xml) if block
end
end
end.doc.root
Expand Down Expand Up @@ -65,8 +66,8 @@ def initialize(trans, os_type)
end
end

def method_missing(method, params = nil, attrs = nil)
@trans.rpc_exec(Netconf::RPC::Builder.send(method, params, attrs))
def method_missing(method, params = nil, attrs = nil, &block)
@trans.rpc_exec(Netconf::RPC::Builder.send(method, params, attrs, &block))
end
end # class: Executor
end # module: RPC
Expand Down