You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expose_nildelegates to the underlying object and doesn't test whether the method is delegatable? This can lead to odd behaviour and errors.
You'd probably have to be doing inheritance with your Entities in order to encounter it in the wild, but as a contrived example:
classMyEntity < ::Grape::Entityexpose:foo,expose_nil: falsedeffoo'forty-foo'endendclassFooableClassdefinitialize(foo=nil)@foo=fooenddeffoo@fooendendclassNoFooFoYouend# In all 3 of the following, I'd argue that the expected result is {:foo=>'forty-foo'}MyEntity.represent(FooableClass.new(42)).as_json# => {:foo=>'forty-foo'}MyEntity.represent(FooableClass.new).as_json# => {}MyEntity.represent(NoFooFoYou.new).as_jsonNoMethodError: undefinedmethod `foo' for#<NoFooFoYou:>
Would you agree this is an issue?
The text was updated successfully, but these errors were encountered:
expose_nil
delegates to the underlying object and doesn't test whether the method isdelegatable?
This can lead to odd behaviour and errors.You'd probably have to be doing inheritance with your Entities in order to encounter it in the wild, but as a contrived example:
Would you agree this is an issue?
The text was updated successfully, but these errors were encountered: