ondemand
ondemand copied to clipboard
SessionContext using missing_method + Enumerable is problematic
SessionContext uses missing_method to resolve context.extra_jupyter_args
to the value of the attribute "extra_jupyter_args" in the hash contained in the context object.
The problem is that SessionContext includes Enumerable (along with ActiveModel etc.) so any methods already defined on SessionContext never hit this block. This means that we cannot do context.partition
because that happens to be a method on Enumerable.
The context of the erb rendering could use an OpenStruct around the hash of attributes instead. An accessor on SessionContext to get the OpenStruct representation may work.
┆Issue is synchronized with this Asana task by Unito
[9] pry(main)> p = OpenStruct.new(partition: "debug", display: 1)
=> #<OpenStruct partition="debug", display=1>
[10] pry(main)> p.display
#<OpenStruct partition="debug", display=1>=> nil
[11] pry(main)> p[:partition]
=> "debug"
[12] pry(main)> p[:display]
=> 1
Every object we try to use with methods for the attribute names is going to be problematic. But a hash like object where we use a symbol for the key will work for everything.