benchmarks/with_defaults.rb in dry-initializer-1.4.1 vs benchmarks/with_defaults.rb in dry-initializer-2.0.0

- old
+ new

@@ -1,24 +1,31 @@ Bundler.require(:benchmarks) +require "dry-initializer" +class DryTest + extend Dry::Initializer[undefined: false] + + option :foo, default: -> { "FOO" } + option :bar, default: -> { "BAR" } +end + +class DryTestUndefined + extend Dry::Initializer + + option :foo, default: -> { "FOO" } + option :bar, default: -> { "BAR" } +end + class PlainRubyTest attr_reader :foo, :bar def initialize(foo: "FOO", bar: "BAR") @foo = foo @bar = bar end end -require "dry-initializer" -class DryTest - extend Dry::Initializer::Mixin - - option :foo, default: proc { "FOO" } - option :bar, default: proc { "BAR" } -end - require "kwattr" class KwattrTest kwattr foo: "FOO", bar: "BAR" end @@ -39,9 +46,13 @@ PlainRubyTest.new end x.report("dry-initializer") do DryTest.new + end + + x.report("dry-initializer (with UNDEFINED)") do + DryTestUndefined.new end x.report("kwattr") do KwattrTest.new end