Is it possible to pass variables from init to script_params?

Just wondering if it's possible to pass along variables from the "init" section of the Ruby filter plugin to the script_params?

In my case the data I am looking up is something I only want to do once:

ruby {
    init => "
      @my_variable = 'expensive lookup'
    "

    path => "/path/to/my/import.rb"

    script_params => {
      "my_variable" => @my_variable
    }
}

Yes, that will work.

1 Like