ondemand icon indicating copy to clipboard operation
ondemand copied to clipboard

SessionContext using missing_method + Enumerable is problematic

Open ericfranz opened this issue 3 years ago • 1 comments

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

ericfranz avatar Jul 22 '20 10:07 ericfranz

[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.

ericfranz avatar Aug 04 '20 20:08 ericfranz