diff --git a/lib/blueprinter/v2.rb b/lib/blueprinter/v2.rb index 324f1542..70c7b061 100644 --- a/lib/blueprinter/v2.rb +++ b/lib/blueprinter/v2.rb @@ -2,13 +2,21 @@ module Blueprinter class V2 + Options = Struct.new( + :exclude_nil, + keyword_init: true, + ) + class << self - attr_accessor :views, :fields, :extensions, :blueprint_name + attr_accessor :views, :fields, :extensions, :options, :blueprint_name end self.views = {} self.fields = {} self.extensions = [] + self.options = Options.new( + exclude_nil: false, + ) self.blueprint_name = [] # Initialize subclass @@ -16,6 +24,7 @@ def self.inherited(subclass) subclass.views = { default: subclass } subclass.fields = fields.dup subclass.extensions = extensions.dup + subclass.options = options.dup subclass.blueprint_name = subclass.name ? [subclass.name] : blueprint_name.dup end