dry-types 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +378 -206
- data/LICENSE +17 -17
- data/README.md +14 -13
- data/dry-types.gemspec +27 -31
- data/lib/dry/types.rb +7 -11
- data/lib/dry/types/any.rb +2 -2
- data/lib/dry/types/array/member.rb +3 -3
- data/lib/dry/types/builder.rb +5 -1
- data/lib/dry/types/builder_methods.rb +22 -8
- data/lib/dry/types/coercions.rb +6 -0
- data/lib/dry/types/coercions/params.rb +1 -1
- data/lib/dry/types/compiler.rb +2 -2
- data/lib/dry/types/constrained.rb +2 -2
- data/lib/dry/types/constructor.rb +7 -34
- data/lib/dry/types/constructor/function.rb +17 -31
- data/lib/dry/types/core.rb +3 -1
- data/lib/dry/types/decorator.rb +3 -9
- data/lib/dry/types/default.rb +2 -2
- data/lib/dry/types/enum.rb +2 -2
- data/lib/dry/types/errors.rb +5 -5
- data/lib/dry/types/extensions.rb +4 -0
- data/lib/dry/types/extensions/maybe.rb +14 -14
- data/lib/dry/types/extensions/monads.rb +29 -0
- data/lib/dry/types/hash.rb +3 -2
- data/lib/dry/types/lax.rb +2 -5
- data/lib/dry/types/meta.rb +3 -3
- data/lib/dry/types/module.rb +3 -3
- data/lib/dry/types/nominal.rb +1 -1
- data/lib/dry/types/params.rb +6 -0
- data/lib/dry/types/predicate_inferrer.rb +197 -0
- data/lib/dry/types/predicate_registry.rb +34 -0
- data/lib/dry/types/primitive_inferrer.rb +97 -0
- data/lib/dry/types/printer.rb +7 -3
- data/lib/dry/types/result.rb +2 -2
- data/lib/dry/types/schema.rb +23 -2
- data/lib/dry/types/schema/key.rb +16 -3
- data/lib/dry/types/spec/types.rb +14 -1
- data/lib/dry/types/sum.rb +5 -5
- data/lib/dry/types/version.rb +1 -1
- metadata +26 -45
- data/.codeclimate.yml +0 -15
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -27
- data/.yardopts +0 -9
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -27
- data/Rakefile +0 -22
- data/benchmarks/hash_schemas.rb +0 -55
- data/benchmarks/lax_schema.rb +0 -15
- data/benchmarks/profile_invalid_input.rb +0 -15
- data/benchmarks/profile_lax_schema_valid.rb +0 -16
- data/benchmarks/profile_valid_input.rb +0 -15
- data/benchmarks/schema_valid_vs_invalid.rb +0 -21
- data/benchmarks/setup.rb +0 -17
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2015-2020 dry-rb team
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/dry-types
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[coveralls]: https://coveralls.io/r/dry-rb/dry-types
|
5
|
-
[inchpages]: http://inch-ci.org/github/dry-rb/dry-types
|
2
|
+
[actions]: https://github.com/dry-rb/dry-types/actions
|
3
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-types
|
6
4
|
[chat]: https://dry-rb.zulipchat.com
|
5
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-types
|
7
6
|
|
8
7
|
# dry-types [][chat]
|
9
8
|
|
10
9
|
[][gem]
|
11
|
-
[][actions]
|
11
|
+
[][codacy]
|
12
|
+
[][codacy]
|
14
13
|
[][inchpages]
|
15
14
|
|
16
15
|
## Links
|
17
16
|
|
18
|
-
* [
|
17
|
+
* [User documentation](http://dry-rb.org/gems/dry-types)
|
18
|
+
* [API documentation](http://rubydoc.info/gems/dry-types)
|
19
19
|
|
20
|
-
##
|
20
|
+
## Supported Ruby versions
|
21
21
|
|
22
|
-
|
22
|
+
This library officially supports the following Ruby versions:
|
23
23
|
|
24
|
-
|
24
|
+
* MRI >= `2.4`
|
25
|
+
* jruby >= `9.2`
|
25
26
|
|
26
|
-
##
|
27
|
+
## License
|
27
28
|
|
28
|
-
|
29
|
+
See `LICENSE` file.
|
data/dry-types.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
# this file is managed by dry-rb/devtools project
|
2
3
|
|
3
4
|
lib = File.expand_path('lib', __dir__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -6,42 +7,37 @@ require 'dry/types/version'
|
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
9
|
spec.name = 'dry-types'
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.email = ['piotr.solnica@gmail.com']
|
10
|
+
spec.authors = ["Piotr Solnica"]
|
11
|
+
spec.email = ["piotr.solnica@gmail.com"]
|
12
12
|
spec.license = 'MIT'
|
13
|
+
spec.version = Dry::Types::VERSION.dup
|
13
14
|
|
14
|
-
spec.summary =
|
15
|
+
spec.summary = "Type system for Ruby supporting coercions, constraints and complex types like structs, value objects, enums etc"
|
15
16
|
spec.description = spec.summary
|
16
|
-
spec.homepage = 'https://
|
17
|
+
spec.homepage = 'https://dry-rb.org/gems/dry-types'
|
18
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-types.gemspec", "lib/**/*"]
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = []
|
21
|
+
spec.require_paths = ['lib']
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md'
|
23
|
-
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-types'
|
24
|
-
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-types/issues'
|
25
|
-
else
|
26
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
27
|
-
end
|
23
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md'
|
25
|
+
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-types'
|
26
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-types/issues'
|
28
27
|
|
29
|
-
spec.
|
30
|
-
spec.bindir = 'exe'
|
31
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = ['lib']
|
33
|
-
spec.required_ruby_version = '>= 2.4.0'
|
28
|
+
spec.required_ruby_version = ">= 2.4.0"
|
34
29
|
|
35
|
-
|
36
|
-
spec.add_runtime_dependency
|
37
|
-
spec.add_runtime_dependency
|
38
|
-
spec.add_runtime_dependency
|
39
|
-
spec.add_runtime_dependency
|
40
|
-
spec.add_runtime_dependency
|
30
|
+
# to update dependencies edit project.yml
|
31
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
32
|
+
spec.add_runtime_dependency "dry-container", "~> 0.3"
|
33
|
+
spec.add_runtime_dependency "dry-core", "~> 0.4", ">= 0.4.4"
|
34
|
+
spec.add_runtime_dependency "dry-equalizer", "~> 0.3"
|
35
|
+
spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
|
36
|
+
spec.add_runtime_dependency "dry-logic", "~> 1.0", ">= 1.0.2"
|
41
37
|
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_development_dependency
|
45
|
-
spec.add_development_dependency
|
46
|
-
spec.add_development_dependency
|
38
|
+
spec.add_development_dependency "bundler"
|
39
|
+
spec.add_development_dependency "dry-monads", "~> 1.0"
|
40
|
+
spec.add_development_dependency "rake"
|
41
|
+
spec.add_development_dependency "rspec"
|
42
|
+
spec.add_development_dependency "yard"
|
47
43
|
end
|
data/lib/dry/types.rb
CHANGED
@@ -89,7 +89,7 @@ module Dry
|
|
89
89
|
def self.[](name)
|
90
90
|
type_map.fetch_or_store(name) do
|
91
91
|
case name
|
92
|
-
when String
|
92
|
+
when ::String
|
93
93
|
result = name.match(TYPE_SPEC_REGEX)
|
94
94
|
|
95
95
|
if result
|
@@ -98,7 +98,12 @@ module Dry
|
|
98
98
|
else
|
99
99
|
container[name]
|
100
100
|
end
|
101
|
-
when Class
|
101
|
+
when ::Class
|
102
|
+
warn(<<~DEPRECATION)
|
103
|
+
Using Dry::Types.[] with a class is deprecated, please use string identifiers: Dry::Types[Integer] -> Dry::Types['integer'].
|
104
|
+
If you're using dry-struct this means changing `attribute :counter, Integer` to `attribute :counter, Dry::Types['integer']` or to `attribute :counter, 'integer'`.
|
105
|
+
DEPRECATION
|
106
|
+
|
102
107
|
type_name = identifier(name)
|
103
108
|
|
104
109
|
if container.key?(type_name)
|
@@ -128,15 +133,6 @@ module Dry
|
|
128
133
|
@type_map ||= Concurrent::Map.new
|
129
134
|
end
|
130
135
|
|
131
|
-
# List of type keys defined in {Dry::Types.container}
|
132
|
-
#
|
133
|
-
# @return [String]
|
134
|
-
#
|
135
|
-
# @api private
|
136
|
-
def self.type_keys
|
137
|
-
container.keys
|
138
|
-
end
|
139
|
-
|
140
136
|
# @api private
|
141
137
|
def self.const_missing(const)
|
142
138
|
underscored = Inflector.underscore(const)
|
data/lib/dry/types/any.rb
CHANGED
@@ -15,7 +15,7 @@ module Dry
|
|
15
15
|
|
16
16
|
# @api private
|
17
17
|
def initialize(**options)
|
18
|
-
super(::Object, options)
|
18
|
+
super(::Object, **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return [String]
|
@@ -30,7 +30,7 @@ module Dry
|
|
30
30
|
# @return [Type]
|
31
31
|
#
|
32
32
|
# @api public
|
33
|
-
def with(new_options)
|
33
|
+
def with(**new_options)
|
34
34
|
self.class.new(**options, meta: @meta, **new_options)
|
35
35
|
end
|
36
36
|
|
@@ -18,7 +18,7 @@ module Dry
|
|
18
18
|
# @option options [Type] :member
|
19
19
|
#
|
20
20
|
# @api private
|
21
|
-
def initialize(primitive, options
|
21
|
+
def initialize(primitive, **options)
|
22
22
|
@member = options.fetch(:member)
|
23
23
|
super
|
24
24
|
end
|
@@ -89,7 +89,7 @@ module Dry
|
|
89
89
|
block ? yield(failure) : failure
|
90
90
|
end
|
91
91
|
else
|
92
|
-
failure = failure(input, "#{input} is not an array")
|
92
|
+
failure = failure(input, CoercionError.new("#{input} is not an array"))
|
93
93
|
block ? yield(failure) : failure
|
94
94
|
end
|
95
95
|
end
|
@@ -100,7 +100,7 @@ module Dry
|
|
100
100
|
#
|
101
101
|
# @api public
|
102
102
|
def lax
|
103
|
-
Lax.new(Member.new(primitive,
|
103
|
+
Lax.new(Member.new(primitive, **options, member: member.lax, meta: meta))
|
104
104
|
end
|
105
105
|
|
106
106
|
# @see Nominal#to_ast
|
data/lib/dry/types/builder.rb
CHANGED
@@ -127,8 +127,12 @@ module Dry
|
|
127
127
|
#
|
128
128
|
# @api public
|
129
129
|
def constructor(constructor = nil, **options, &block)
|
130
|
-
constructor_type.new(with(options), fn: constructor || block)
|
130
|
+
constructor_type.new(with(**options), fn: constructor || block)
|
131
131
|
end
|
132
|
+
alias_method :append, :constructor
|
133
|
+
alias_method :prepend, :constructor
|
134
|
+
alias_method :>>, :constructor
|
135
|
+
alias_method :<<, :constructor
|
132
136
|
end
|
133
137
|
end
|
134
138
|
end
|
@@ -25,7 +25,7 @@ module Dry
|
|
25
25
|
#
|
26
26
|
# @return [Dry::Types::Array]
|
27
27
|
def Array(type)
|
28
|
-
|
28
|
+
Strict(::Array).of(type)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Build a hash schema
|
@@ -34,7 +34,7 @@ module Dry
|
|
34
34
|
#
|
35
35
|
# @return [Dry::Types::Array]
|
36
36
|
def Hash(type_map)
|
37
|
-
|
37
|
+
Strict(::Hash).schema(type_map)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Build a type which values are instances of a given class
|
@@ -49,7 +49,7 @@ module Dry
|
|
49
49
|
#
|
50
50
|
# @return [Dry::Types::Type]
|
51
51
|
def Instance(klass)
|
52
|
-
Nominal
|
52
|
+
Nominal(klass).constrained(type: klass)
|
53
53
|
end
|
54
54
|
alias_method :Strict, :Instance
|
55
55
|
|
@@ -60,7 +60,7 @@ module Dry
|
|
60
60
|
#
|
61
61
|
# @return [Dry::Types::Type]
|
62
62
|
def Value(value)
|
63
|
-
Nominal
|
63
|
+
Nominal(value.class).constrained(eql: value)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Build a type with a single value
|
@@ -70,7 +70,7 @@ module Dry
|
|
70
70
|
#
|
71
71
|
# @return [Dry::Types::Type]
|
72
72
|
def Constant(object)
|
73
|
-
Nominal
|
73
|
+
Nominal(object.class).constrained(is: object)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Build a constructor type
|
@@ -82,7 +82,15 @@ module Dry
|
|
82
82
|
#
|
83
83
|
# @return [Dry::Types::Type]
|
84
84
|
def Constructor(klass, cons = nil, &block)
|
85
|
-
|
85
|
+
if klass.is_a?(Type)
|
86
|
+
if cons || block
|
87
|
+
klass.constructor(cons || block)
|
88
|
+
else
|
89
|
+
klass
|
90
|
+
end
|
91
|
+
else
|
92
|
+
Nominal(klass).constructor(cons || block || klass.method(:new))
|
93
|
+
end
|
86
94
|
end
|
87
95
|
|
88
96
|
# Build a nominal type
|
@@ -91,7 +99,13 @@ module Dry
|
|
91
99
|
#
|
92
100
|
# @return [Dry::Types::Type]
|
93
101
|
def Nominal(klass)
|
94
|
-
|
102
|
+
if klass <= ::Array
|
103
|
+
Array.new(klass)
|
104
|
+
elsif klass <= ::Hash
|
105
|
+
Hash.new(klass)
|
106
|
+
else
|
107
|
+
Nominal.new(klass)
|
108
|
+
end
|
95
109
|
end
|
96
110
|
|
97
111
|
# Build a map type
|
@@ -105,7 +119,7 @@ module Dry
|
|
105
119
|
#
|
106
120
|
# @return [Dry::Types::Map]
|
107
121
|
def Map(key_type, value_type)
|
108
|
-
|
122
|
+
Nominal(::Hash).map(key_type, value_type)
|
109
123
|
end
|
110
124
|
|
111
125
|
# Builds a constrained nominal type accepting any value that
|
data/lib/dry/types/coercions.rb
CHANGED
@@ -39,6 +39,8 @@ module Dry
|
|
39
39
|
rescue ArgumentError, RangeError => e
|
40
40
|
CoercionError.handle(e, &block)
|
41
41
|
end
|
42
|
+
elsif input.is_a?(::Date)
|
43
|
+
input
|
42
44
|
elsif block_given?
|
43
45
|
yield
|
44
46
|
else
|
@@ -60,6 +62,8 @@ module Dry
|
|
60
62
|
rescue ArgumentError => e
|
61
63
|
CoercionError.handle(e, &block)
|
62
64
|
end
|
65
|
+
elsif input.is_a?(::DateTime)
|
66
|
+
input
|
63
67
|
elsif block_given?
|
64
68
|
yield
|
65
69
|
else
|
@@ -81,6 +85,8 @@ module Dry
|
|
81
85
|
rescue ArgumentError => e
|
82
86
|
CoercionError.handle(e, &block)
|
83
87
|
end
|
88
|
+
elsif input.is_a?(::Time)
|
89
|
+
input
|
84
90
|
elsif block_given?
|
85
91
|
yield
|
86
92
|
else
|
@@ -14,7 +14,7 @@ module Dry
|
|
14
14
|
FALSE_VALUES = %w[0 off Off OFF f false False FALSE F n no No NO N].freeze
|
15
15
|
BOOLEAN_MAP = ::Hash[
|
16
16
|
TRUE_VALUES.product([true]) + FALSE_VALUES.product([false])
|
17
|
-
].freeze
|
17
|
+
].merge(true => true, false => false).freeze
|
18
18
|
|
19
19
|
extend Coercions
|
20
20
|
|
data/lib/dry/types/compiler.rb
CHANGED
@@ -68,12 +68,12 @@ module Dry
|
|
68
68
|
|
69
69
|
def visit_hash(node)
|
70
70
|
opts, meta = node
|
71
|
-
registry['nominal.hash'].with(opts
|
71
|
+
registry['nominal.hash'].with(**opts, meta: meta)
|
72
72
|
end
|
73
73
|
|
74
74
|
def visit_schema(node)
|
75
75
|
keys, options, meta = node
|
76
|
-
registry['nominal.hash'].schema(keys.map { |key| visit(key) }).with(options
|
76
|
+
registry['nominal.hash'].schema(keys.map { |key| visit(key) }).with(**options, meta: meta)
|
77
77
|
end
|
78
78
|
|
79
79
|
def visit_json_hash(node)
|
@@ -14,7 +14,7 @@ module Dry
|
|
14
14
|
include Decorator
|
15
15
|
include Builder
|
16
16
|
include Printable
|
17
|
-
include Dry::Equalizer(:type, :rule, inspect: false)
|
17
|
+
include Dry::Equalizer(:type, :rule, inspect: false, immutable: true)
|
18
18
|
|
19
19
|
# @return [Dry::Logic::Rule]
|
20
20
|
attr_reader :rule
|
@@ -24,7 +24,7 @@ module Dry
|
|
24
24
|
# @param [Hash] options
|
25
25
|
#
|
26
26
|
# @api public
|
27
|
-
def initialize(type, options)
|
27
|
+
def initialize(type, **options)
|
28
28
|
super
|
29
29
|
@rule = options.fetch(:rule)
|
30
30
|
end
|
@@ -10,9 +10,7 @@ module Dry
|
|
10
10
|
#
|
11
11
|
# @api public
|
12
12
|
class Constructor < Nominal
|
13
|
-
include Dry::Equalizer(:type, :options, inspect: false)
|
14
|
-
|
15
|
-
private :meta
|
13
|
+
include Dry::Equalizer(:type, :options, inspect: false, immutable: true)
|
16
14
|
|
17
15
|
# @return [#call]
|
18
16
|
attr_reader :fn
|
@@ -20,7 +18,7 @@ module Dry
|
|
20
18
|
# @return [Type]
|
21
19
|
attr_reader :type
|
22
20
|
|
23
|
-
undef :constrained
|
21
|
+
undef :constrained?, :meta, :optional?, :primitive, :default?, :name
|
24
22
|
|
25
23
|
# @param [Builder, Object] input
|
26
24
|
# @param [Hash] options
|
@@ -46,31 +44,6 @@ module Dry
|
|
46
44
|
super(type, **options, fn: fn)
|
47
45
|
end
|
48
46
|
|
49
|
-
# Return the inner type's primitive
|
50
|
-
#
|
51
|
-
# @return [Class]
|
52
|
-
#
|
53
|
-
# @api public
|
54
|
-
def primitive
|
55
|
-
type.primitive
|
56
|
-
end
|
57
|
-
|
58
|
-
# Return the inner type's name
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
#
|
62
|
-
# @api public
|
63
|
-
def name
|
64
|
-
type.name
|
65
|
-
end
|
66
|
-
|
67
|
-
# @return [Boolean]
|
68
|
-
#
|
69
|
-
# @api public
|
70
|
-
def default?
|
71
|
-
type.default?
|
72
|
-
end
|
73
|
-
|
74
47
|
# @return [Object]
|
75
48
|
#
|
76
49
|
# @api private
|
@@ -112,7 +85,7 @@ module Dry
|
|
112
85
|
#
|
113
86
|
# @api public
|
114
87
|
def constructor(new_fn = nil, **options, &block)
|
115
|
-
with(
|
88
|
+
with(**options, fn: fn >> (new_fn || block))
|
116
89
|
end
|
117
90
|
alias_method :append, :constructor
|
118
91
|
alias_method :>>, :constructor
|
@@ -141,7 +114,7 @@ module Dry
|
|
141
114
|
#
|
142
115
|
# @api public
|
143
116
|
def prepend(new_fn = nil, **options, &block)
|
144
|
-
with(
|
117
|
+
with(**options, fn: fn << (new_fn || block))
|
145
118
|
end
|
146
119
|
alias_method :<<, :prepend
|
147
120
|
|
@@ -150,7 +123,7 @@ module Dry
|
|
150
123
|
# @return [Lax]
|
151
124
|
# @api public
|
152
125
|
def lax
|
153
|
-
Lax.new(Constructor.new(type.lax, options))
|
126
|
+
Lax.new(Constructor.new(type.lax, **options))
|
154
127
|
end
|
155
128
|
|
156
129
|
# Wrap the type with a proc
|
@@ -182,10 +155,10 @@ module Dry
|
|
182
155
|
# @api private
|
183
156
|
def method_missing(method, *args, &block)
|
184
157
|
if type.respond_to?(method)
|
185
|
-
response = type.
|
158
|
+
response = type.public_send(method, *args, &block)
|
186
159
|
|
187
160
|
if response.is_a?(Type) && type.class == response.class
|
188
|
-
response.constructor_type.new(response, options)
|
161
|
+
response.constructor_type.new(response, **options)
|
189
162
|
else
|
190
163
|
response
|
191
164
|
end
|