Skip to content

Commit

Permalink
Add options for things that don't make sense as extension hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Hollinger <[email protected]>
  • Loading branch information
jhollinger committed Jul 15, 2024
1 parent 64bd92b commit 6dd4924
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/blueprinter/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@

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

Expand Down

0 comments on commit 6dd4924

Please sign in to comment.