lib/aerospike/client.rb
def register_udf(udf_body, server_path, language, options = nil)
      policy = create_policy(options, Policy, default_info_policy)

      content = Base64.strict_encode64(udf_body).force_encoding('binary')
      str_cmd = "udf-put:filename=#{server_path};content=#{content};"
      str_cmd << "content-len=#{content.length};udf-type=#{language};"

      # Send UDF to one node. That node will distribute the UDF to other nodes.
      response_map = @cluster.request_info(policy, str_cmd)

      res = {}
      response_map.each do |k, response|
        vals = response.to_s.split(';')
        vals.each do |pair|
          k, v = pair.split("=", 2)
          res[k] = v
        end
      end

      if res['error']
        raise Aerospike::Exceptions::CommandRejected.new("Registration failed: #{res['error']}\nFile: #{res['file']}\nLine: #{res['line']}\nMessage: #{res['message']}")
      end

      UdfRegisterTask.new(@cluster, server_path)
    end
def register_udf(udf_body, server_path, language, options = nil)
      policy = create_policy(options, Policy, default_info_policy)

      content = Base64.strict_encode64(udf_body).force_encoding('binary')
      str_cmd = "udf-put:filename=#{server_path};content=#{content};"
      str_cmd << "content-len=#{content.length};udf-type=#{language};"

      # Send UDF to one node. That node will distribute the UDF to other nodes.
      response_map = @cluster.request_info(policy, str_cmd)

      res = {}
      response_map.each do |k, response|
        vals = response.to_s.split(';')
        vals.each do |pair|
          k, v = pair.split("=", 2)
          res[k] = v
        end
      end

      if res['error']
        raise Aerospike::Exceptions::CommandRejected.new("Registration failed: #{res['error']}\nFile: #{res['file']}\nLine: #{res['line']}\nMessage: #{res['message']}")
      end

      UdfRegisterTask.new(@cluster, server_path)
    end
Register package containing user defined functions with server.
  This asynchronous server call will return before command is complete.
  The user can optionally wait for command completion by using the returned
  RegisterTask instance.

  This method is only supported by Aerospike 3 servers.