Closed ygaitonde closed 2 years ago
This could probably be more clear in the documentation but nil
is a special case that doesn't pass through. Giving a default value of nil
is how a filter is made optional. What you want is:
class Foo < ActiveInteraction::Base
object :x, class: Bar, converter: :new, default: Bar.new(nil)
def execute
x
end
end
I'll update the docs to clarify.
This code doesn't try and cast nil, and instead just sets the object to nil, causing a
NoMethodError
when we expect400
to be printed.From the docs:
The value given to the default option will also be converted.
Happy to take a stab at fixing this.