dry-initializer 2.4.0 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +10 -21
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---bug-report.md +30 -0
- data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
- data/.github/workflows/custom_ci.yml +58 -0
- data/.github/workflows/docsite.yml +34 -0
- data/.github/workflows/sync_configs.yml +56 -0
- data/.gitignore +2 -0
- data/.rspec +1 -1
- data/.rubocop.yml +76 -25
- data/CHANGELOG.md +150 -14
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +25 -18
- data/Gemfile.devtools +16 -0
- data/Guardfile +3 -3
- data/LICENSE +20 -0
- data/README.md +17 -79
- data/Rakefile +4 -4
- data/benchmarks/compare_several_defaults.rb +27 -27
- data/benchmarks/plain_options.rb +14 -14
- data/benchmarks/plain_params.rb +22 -22
- data/benchmarks/with_coercion.rb +14 -14
- data/benchmarks/with_defaults.rb +17 -17
- data/benchmarks/with_defaults_and_coercion.rb +14 -14
- data/bin/.gitkeep +0 -0
- data/docsite/source/attributes.html.md +106 -0
- data/docsite/source/container-version.html.md +39 -0
- data/docsite/source/index.html.md +43 -0
- data/docsite/source/inheritance.html.md +43 -0
- data/docsite/source/optionals-and-defaults.html.md +130 -0
- data/docsite/source/options-tolerance.html.md +27 -0
- data/docsite/source/params-and-options.html.md +74 -0
- data/docsite/source/rails-support.html.md +101 -0
- data/docsite/source/readers.html.md +43 -0
- data/docsite/source/skip-undefined.html.md +59 -0
- data/docsite/source/type-constraints.html.md +160 -0
- data/dry-initializer.gemspec +13 -13
- data/lib/dry-initializer.rb +1 -1
- data/lib/dry/initializer.rb +17 -16
- data/lib/dry/initializer/builders.rb +2 -2
- data/lib/dry/initializer/builders/attribute.rb +16 -11
- data/lib/dry/initializer/builders/initializer.rb +9 -13
- data/lib/dry/initializer/builders/reader.rb +4 -2
- data/lib/dry/initializer/builders/signature.rb +3 -3
- data/lib/dry/initializer/config.rb +25 -12
- data/lib/dry/initializer/definition.rb +20 -71
- data/lib/dry/initializer/dispatchers.rb +101 -33
- data/lib/dry/initializer/dispatchers/build_nested_type.rb +59 -0
- data/lib/dry/initializer/dispatchers/check_type.rb +43 -0
- data/lib/dry/initializer/dispatchers/prepare_default.rb +40 -0
- data/lib/dry/initializer/dispatchers/prepare_ivar.rb +12 -0
- data/lib/dry/initializer/dispatchers/prepare_optional.rb +13 -0
- data/lib/dry/initializer/dispatchers/prepare_reader.rb +30 -0
- data/lib/dry/initializer/dispatchers/prepare_source.rb +28 -0
- data/lib/dry/initializer/dispatchers/prepare_target.rb +44 -0
- data/lib/dry/initializer/dispatchers/unwrap_type.rb +22 -0
- data/lib/dry/initializer/dispatchers/wrap_type.rb +28 -0
- data/lib/dry/initializer/mixin.rb +4 -4
- data/lib/dry/initializer/mixin/root.rb +1 -0
- data/lib/dry/initializer/struct.rb +39 -0
- data/lib/dry/initializer/undefined.rb +2 -0
- data/lib/dry/initializer/version.rb +5 -0
- data/lib/tasks/benchmark.rake +13 -13
- data/lib/tasks/profile.rake +16 -16
- data/project.yml +2 -0
- data/spec/attributes_spec.rb +7 -7
- data/spec/coercion_of_nil_spec.rb +25 -0
- data/spec/custom_dispatchers_spec.rb +6 -6
- data/spec/custom_initializer_spec.rb +2 -2
- data/spec/default_values_spec.rb +9 -9
- data/spec/definition_spec.rb +16 -12
- data/spec/invalid_default_spec.rb +2 -2
- data/spec/list_type_spec.rb +32 -0
- data/spec/missed_default_spec.rb +2 -2
- data/spec/nested_type_spec.rb +48 -0
- data/spec/optional_spec.rb +16 -16
- data/spec/options_tolerance_spec.rb +2 -2
- data/spec/public_attributes_utility_spec.rb +5 -5
- data/spec/reader_spec.rb +13 -13
- data/spec/repetitive_definitions_spec.rb +9 -9
- data/spec/several_assignments_spec.rb +9 -9
- data/spec/spec_helper.rb +6 -3
- data/spec/subclassing_spec.rb +5 -5
- data/spec/support/coverage.rb +7 -0
- data/spec/support/warnings.rb +7 -0
- data/spec/type_argument_spec.rb +15 -15
- data/spec/type_constraint_spec.rb +46 -28
- data/spec/value_coercion_via_dry_types_spec.rb +8 -8
- metadata +51 -34
- data/.travis.yml +0 -24
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Takes `:type` and `:wrap` to construct the final value coercer
|
3
|
+
#
|
4
|
+
module Dry::Initializer::Dispatchers::WrapType
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def call(type: nil, wrap: 0, **options)
|
8
|
+
{ type: wrapped_type(type, wrap), **options }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def wrapped_type(type, count)
|
14
|
+
return type if count.zero?
|
15
|
+
|
16
|
+
->(value) { wrap_value(value, count, type) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def wrap_value(value, count, type)
|
20
|
+
if count.zero?
|
21
|
+
type ? type.call(value) : value
|
22
|
+
else
|
23
|
+
return [wrap_value(value, count - 1, type)] unless value.is_a?(Array)
|
24
|
+
|
25
|
+
value.map { |item| wrap_value(item, count - 1, type) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -4,12 +4,12 @@ module Dry::Initializer
|
|
4
4
|
extend DSL # @deprecated
|
5
5
|
include Dry::Initializer # @deprecated
|
6
6
|
def self.extended(klass) # @deprecated
|
7
|
-
warn
|
8
|
-
|
7
|
+
warn '[DEPRECATED] Use Dry::Initializer instead of its alias' \
|
8
|
+
' Dry::Initializer::Mixin. The later will be removed in v2.1.0'
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
|
-
require_relative
|
13
|
-
require_relative
|
12
|
+
require_relative 'mixin/root'
|
13
|
+
require_relative 'mixin/local'
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# The nested structure that takes nested hashes with indifferent access
|
3
|
+
#
|
4
|
+
class Dry::Initializer::Struct
|
5
|
+
extend Dry::Initializer
|
6
|
+
|
7
|
+
class << self
|
8
|
+
undef_method :param
|
9
|
+
|
10
|
+
def new(options)
|
11
|
+
super(**Hash(options).each_with_object({}) { |(k, v), h| h[k.to_sym] = v })
|
12
|
+
end
|
13
|
+
alias call new
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Represents event data as a nested hash with deeply stringified keys
|
18
|
+
# @return [Hash<String, ...>]
|
19
|
+
#
|
20
|
+
def to_h
|
21
|
+
self
|
22
|
+
.class
|
23
|
+
.dry_initializer
|
24
|
+
.attributes(self)
|
25
|
+
.each_with_object({}) { |(k, v), h| h[k.to_s] = __hashify(v) }
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def __hashify(value)
|
31
|
+
case value
|
32
|
+
when Hash
|
33
|
+
value.each_with_object({}) { |(k, v), obj| obj[k.to_s] = __hashify(v) }
|
34
|
+
when Array then value.map { |v| __hashify(v) }
|
35
|
+
when Dry::Initializer::Struct then value.to_h
|
36
|
+
else value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/tasks/benchmark.rake
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
namespace :benchmark do
|
2
|
-
desc
|
2
|
+
desc 'Runs benchmarks for plain params'
|
3
3
|
task :plain_params do
|
4
|
-
system
|
4
|
+
system 'ruby benchmarks/plain_params.rb'
|
5
5
|
end
|
6
6
|
|
7
|
-
desc
|
7
|
+
desc 'Runs benchmarks for plain options'
|
8
8
|
task :plain_options do
|
9
|
-
system
|
9
|
+
system 'ruby benchmarks/plain_options.rb'
|
10
10
|
end
|
11
11
|
|
12
|
-
desc
|
12
|
+
desc 'Runs benchmarks for value coercion'
|
13
13
|
task :with_coercion do
|
14
|
-
system
|
14
|
+
system 'ruby benchmarks/with_coercion.rb'
|
15
15
|
end
|
16
16
|
|
17
|
-
desc
|
17
|
+
desc 'Runs benchmarks with defaults'
|
18
18
|
task :with_defaults do
|
19
|
-
system
|
19
|
+
system 'ruby benchmarks/with_defaults.rb'
|
20
20
|
end
|
21
21
|
|
22
|
-
desc
|
22
|
+
desc 'Runs benchmarks with defaults and coercion'
|
23
23
|
task :with_defaults_and_coercion do
|
24
|
-
system
|
24
|
+
system 'ruby benchmarks/with_defaults_and_coercion.rb'
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
27
|
+
desc 'Runs benchmarks for several defaults'
|
28
28
|
task :compare_several_defaults do
|
29
|
-
system
|
29
|
+
system 'ruby benchmarks/with_several_defaults.rb'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
desc
|
33
|
+
desc 'Runs all benchmarks'
|
34
34
|
task benchmark: %i[
|
35
35
|
benchmark:plain_params
|
36
36
|
benchmark:plain_options
|
data/lib/tasks/profile.rake
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
namespace :profile do
|
2
2
|
def profile(name, execution, &definition)
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'dry-initializer'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'fileutils'
|
6
6
|
|
7
7
|
definition.call
|
8
8
|
result = RubyProf.profile do
|
9
9
|
1_000.times { execution.call }
|
10
10
|
end
|
11
11
|
|
12
|
-
FileUtils.mkdir_p
|
12
|
+
FileUtils.mkdir_p './tmp'
|
13
13
|
|
14
14
|
FileUtils.touch "./tmp/#{name}.dot"
|
15
|
-
File.open("./tmp/#{name}.dot",
|
15
|
+
File.open("./tmp/#{name}.dot", 'w+') do |output|
|
16
16
|
RubyProf::DotPrinter.new(result).print(output, min_percent: 0)
|
17
17
|
end
|
18
18
|
|
19
19
|
FileUtils.touch "./tmp/#{name}.html"
|
20
|
-
File.open("./tmp/#{name}.html",
|
20
|
+
File.open("./tmp/#{name}.html", 'w+') do |output|
|
21
21
|
RubyProf::CallStackPrinter.new(result).print(output, min_percent: 0)
|
22
22
|
end
|
23
23
|
|
24
24
|
system "dot -Tpng ./tmp/#{name}.dot > ./tmp/#{name}.png"
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
27
|
+
desc 'Profiles initialization with required param and option'
|
28
28
|
task :required do
|
29
|
-
profile(
|
29
|
+
profile('required', -> { User.new :Andy, email: 'andy@example.com' }) do
|
30
30
|
class User
|
31
31
|
extend Dry::Initializer
|
32
32
|
param :name
|
@@ -35,20 +35,20 @@ namespace :profile do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
desc
|
38
|
+
desc 'Profiles initialization with default param and option'
|
39
39
|
task :defaults do
|
40
|
-
profile(
|
40
|
+
profile('defaults', -> { User.new }) do
|
41
41
|
class User
|
42
42
|
extend Dry::Initializer
|
43
43
|
param :name, default: -> { :Andy }
|
44
|
-
option :email, default: -> {
|
44
|
+
option :email, default: -> { 'andy@example.com' }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
desc
|
49
|
+
desc 'Profiles initialization with coerced param and option'
|
50
50
|
task :coercion do
|
51
|
-
profile(
|
51
|
+
profile('coercion', -> { User.new :Andy, email: :"andy@example.com" }) do
|
52
52
|
class User
|
53
53
|
extend Dry::Initializer
|
54
54
|
param :name, proc(&:to_s)
|
@@ -57,9 +57,9 @@ namespace :profile do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
desc
|
60
|
+
desc 'Profiles initialization with coerced defaults of param and option'
|
61
61
|
task :default_coercion do
|
62
|
-
profile(
|
62
|
+
profile('default_coercion', -> { User.new }) do
|
63
63
|
class User
|
64
64
|
extend Dry::Initializer
|
65
65
|
param :name, proc(&:to_s), default: -> { :Andy }
|
@@ -69,7 +69,7 @@ namespace :profile do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
desc
|
72
|
+
desc 'Makes all profiling at once'
|
73
73
|
task profile: %i[
|
74
74
|
profile:required
|
75
75
|
profile:defaults
|
data/project.yml
ADDED
data/spec/attributes_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
describe Dry::Initializer,
|
1
|
+
describe Dry::Initializer, 'dry_initializer.attributes' do
|
2
2
|
subject { instance.class.dry_initializer.attributes(instance) }
|
3
3
|
|
4
|
-
context
|
4
|
+
context 'when class has params' do
|
5
5
|
before do
|
6
6
|
class Test::Foo
|
7
7
|
extend Dry::Initializer
|
@@ -13,12 +13,12 @@ describe Dry::Initializer, "dry_initializer.attributes" do
|
|
13
13
|
|
14
14
|
let(:instance) { Test::Foo.new(:FOO) }
|
15
15
|
|
16
|
-
it
|
17
|
-
expect(subject).to eq({ foo:
|
16
|
+
it 'collects coerced params with default values' do
|
17
|
+
expect(subject).to eq({ foo: 'FOO', bar: 1 })
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
21
|
+
context 'when class has options' do
|
22
22
|
before do
|
23
23
|
class Test::Foo
|
24
24
|
extend Dry::Initializer
|
@@ -31,8 +31,8 @@ describe Dry::Initializer, "dry_initializer.attributes" do
|
|
31
31
|
|
32
32
|
let(:instance) { Test::Foo.new(foo: :FOO, qux: :QUX) }
|
33
33
|
|
34
|
-
it
|
35
|
-
expect(subject).to eq({ foo: :FOO, bar: 1, quxx:
|
34
|
+
it 'collects coerced and renamed options with default values' do
|
35
|
+
expect(subject).to eq({ foo: :FOO, bar: 1, quxx: 'QUX' })
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe 'coercion of nil' do
|
2
|
+
before do
|
3
|
+
class Test::Foo
|
4
|
+
extend Dry::Initializer
|
5
|
+
param :bar, proc(&:to_i)
|
6
|
+
end
|
7
|
+
|
8
|
+
class Test::Baz
|
9
|
+
include Dry::Initializer.define -> do
|
10
|
+
param :qux, proc(&:to_i)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:foo) { Test::Foo.new(nil) }
|
16
|
+
let(:baz) { Test::Baz.new(nil) }
|
17
|
+
|
18
|
+
it 'works with extend syntax' do
|
19
|
+
expect(foo.bar).to eq 0
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'works with include syntax' do
|
23
|
+
expect(baz.qux).to eq 0
|
24
|
+
end
|
25
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
describe
|
2
|
-
subject { Test::Foo.new
|
1
|
+
describe 'custom dispatchers' do
|
2
|
+
subject { Test::Foo.new '123' }
|
3
3
|
|
4
4
|
before do
|
5
5
|
dispatcher = ->(op) { op[:integer] ? op.merge(type: proc(&:to_i)) : op }
|
6
6
|
Dry::Initializer::Dispatchers << dispatcher
|
7
7
|
end
|
8
8
|
|
9
|
-
context
|
9
|
+
context 'with extend syntax' do
|
10
10
|
before do
|
11
11
|
class Test::Foo
|
12
12
|
extend Dry::Initializer
|
@@ -14,12 +14,12 @@ describe "custom dispatchers" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'adds syntax sugar' do
|
18
18
|
expect(subject.id).to eq 123
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
context
|
22
|
+
context 'with include syntax' do
|
23
23
|
before do
|
24
24
|
class Test::Foo
|
25
25
|
include Dry::Initializer.define -> do
|
@@ -28,7 +28,7 @@ describe "custom dispatchers" do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it 'adds syntax sugar' do
|
32
32
|
expect(subject.id).to eq 123
|
33
33
|
end
|
34
34
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe
|
1
|
+
describe 'custom initializer' do
|
2
2
|
before do
|
3
3
|
class Test::Foo
|
4
4
|
extend Dry::Initializer
|
@@ -21,7 +21,7 @@ describe "custom initializer" do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'reloads the initializer' do
|
25
25
|
baz = Test::Baz.new(5, 5)
|
26
26
|
|
27
27
|
expect(baz.bar).to eq 15 # 5 * 3
|
data/spec/default_values_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
describe
|
1
|
+
describe 'default values' do
|
2
2
|
before do
|
3
3
|
class Test::Foo
|
4
4
|
extend Dry::Initializer
|
@@ -17,7 +17,7 @@ describe "default values" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'instantiate arguments' do
|
21
21
|
subject = Test::Foo.new(1, 2, baz: 3, qux: 4)
|
22
22
|
|
23
23
|
expect(subject.foo).to eql 1
|
@@ -26,7 +26,7 @@ describe "default values" do
|
|
26
26
|
expect(subject.qux).to eql 4
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'applies default values' do
|
30
30
|
subject = Test::Foo.new
|
31
31
|
|
32
32
|
expect(subject.foo).to eql :FOO
|
@@ -35,7 +35,7 @@ describe "default values" do
|
|
35
35
|
expect(subject.qux).to eql :FOO
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'applies default values partially' do
|
39
39
|
subject = Test::Foo.new 1, baz: 3
|
40
40
|
|
41
41
|
expect(subject.foo).to eql 1
|
@@ -44,12 +44,12 @@ describe "default values" do
|
|
44
44
|
expect(subject.qux).to eql 1
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it 'applies default values from private methods' do
|
48
48
|
subject = Test::Foo.new
|
49
49
|
expect(subject.mox).to eql :MOX
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
52
|
+
describe 'when the last param has a default and there are no options' do
|
53
53
|
before do
|
54
54
|
class Test::Bar
|
55
55
|
extend Dry::Initializer
|
@@ -59,21 +59,21 @@ describe "default values" do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
62
|
+
it 'instantiates arguments' do
|
63
63
|
subject = Test::Bar.new(1, 2)
|
64
64
|
|
65
65
|
expect(subject.foo).to eql 1
|
66
66
|
expect(subject.bar).to eql 2
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it 'applies default values' do
|
70
70
|
subject = Test::Bar.new(1)
|
71
71
|
|
72
72
|
expect(subject.foo).to eql 1
|
73
73
|
expect(subject.bar).to eql({})
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'instantiates arguments also if the last is an hash' do
|
77
77
|
subject = Test::Bar.new(1, { baz: 2, qux: 3 })
|
78
78
|
|
79
79
|
expect(subject.foo).to eql 1
|
data/spec/definition_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
describe
|
1
|
+
describe 'definition' do
|
2
2
|
shared_examples :initializer do |in_context|
|
3
3
|
subject { Test::Foo.new(1, bar: 2) }
|
4
4
|
|
@@ -8,7 +8,7 @@ describe "definition" do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
it_behaves_like :initializer,
|
11
|
+
it_behaves_like :initializer, 'extend Dry::Initializer' do
|
12
12
|
before do
|
13
13
|
class Test::Foo
|
14
14
|
extend Dry::Initializer
|
@@ -17,24 +17,28 @@ describe "definition" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'preservers definition params' do
|
21
21
|
params = Test::Foo.dry_initializer.params.map do |definition|
|
22
22
|
[definition.source, definition.options]
|
23
23
|
end
|
24
24
|
|
25
|
-
expect(params).to eq [
|
25
|
+
expect(params).to eq [
|
26
|
+
[:foo, { as: :foo, reader: :public, optional: false }]
|
27
|
+
]
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
30
|
+
it 'preservers definition options' do
|
29
31
|
options = Test::Foo.dry_initializer.options.map do |definition|
|
30
32
|
[definition.source, definition.options]
|
31
33
|
end
|
32
34
|
|
33
|
-
expect(options).to eq [
|
35
|
+
expect(options).to eq [
|
36
|
+
[:bar, { as: :bar, reader: :public, optional: false }]
|
37
|
+
]
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
|
-
it_behaves_like :initializer,
|
41
|
+
it_behaves_like :initializer, 'extend Dry::Initializer' do
|
38
42
|
before do
|
39
43
|
class Test::Foo
|
40
44
|
extend Dry::Initializer
|
@@ -44,7 +48,7 @@ describe "definition" do
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
it_behaves_like :initializer,
|
51
|
+
it_behaves_like :initializer, 'extend Dry::Initializer[undefined: false]' do
|
48
52
|
before do
|
49
53
|
class Test::Foo
|
50
54
|
extend Dry::Initializer[undefined: false]
|
@@ -54,7 +58,7 @@ describe "definition" do
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
57
|
-
it_behaves_like :initializer,
|
61
|
+
it_behaves_like :initializer, 'include Dry::Initializer with block' do
|
58
62
|
before do
|
59
63
|
class Test::Foo
|
60
64
|
include(
|
@@ -67,7 +71,7 @@ describe "definition" do
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
|
-
it_behaves_like :initializer,
|
74
|
+
it_behaves_like :initializer, 'include Dry::Initializer with lambda' do
|
71
75
|
before do
|
72
76
|
class Test::Foo
|
73
77
|
include Dry::Initializer.define -> do
|
@@ -78,7 +82,7 @@ describe "definition" do
|
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
81
|
-
it_behaves_like :initializer,
|
85
|
+
it_behaves_like :initializer, 'include Dry::Initializer[undefined: false]' do
|
82
86
|
before do
|
83
87
|
class Test::Foo
|
84
88
|
include(
|
@@ -92,7 +96,7 @@ describe "definition" do
|
|
92
96
|
end
|
93
97
|
|
94
98
|
# @deprecated
|
95
|
-
it_behaves_like :initializer,
|
99
|
+
it_behaves_like :initializer, 'include Dry::Initializer::Mixin' do
|
96
100
|
before do
|
97
101
|
class Test::Foo
|
98
102
|
include(
|