grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

`with_options` doesn't do deep merge

Open Kukunin opened this issue 8 years ago • 1 comments

      with_options documentation: {required: true, type: 'integer'} do
        expose :posts_count, as: :posts, documentation: {example: 7}
        expose :followers_count, as: :followers, documentation: {example: 105}
        expose :following_count, as: :following, documentation: {example: 52}
        expose :bookmarks_count, as: :bookmarks, documentation: {example: 22}
      end

the example doesn't work, since documentation from nested attributes overrides parent's one.

I think they should be deep merged

Kukunin avatar Nov 08 '17 21:11 Kukunin

I agree that this would be better behavior in this case, but isn't this with_options from ActiveSupport which is sadly not merging options? So it's rather a bug there. This behavior is outlined in the docs. See the first NOTE which goes like this NOTE: Each nesting level will merge inherited defaults in addition to their own. and the text after it.

aCandidMind avatar Sep 10 '18 16:09 aCandidMind