dry-types 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +378 -206
  3. data/LICENSE +17 -17
  4. data/README.md +14 -13
  5. data/dry-types.gemspec +27 -31
  6. data/lib/dry/types.rb +7 -11
  7. data/lib/dry/types/any.rb +2 -2
  8. data/lib/dry/types/array/member.rb +3 -3
  9. data/lib/dry/types/builder.rb +5 -1
  10. data/lib/dry/types/builder_methods.rb +22 -8
  11. data/lib/dry/types/coercions.rb +6 -0
  12. data/lib/dry/types/coercions/params.rb +1 -1
  13. data/lib/dry/types/compiler.rb +2 -2
  14. data/lib/dry/types/constrained.rb +2 -2
  15. data/lib/dry/types/constructor.rb +7 -34
  16. data/lib/dry/types/constructor/function.rb +17 -31
  17. data/lib/dry/types/core.rb +3 -1
  18. data/lib/dry/types/decorator.rb +3 -9
  19. data/lib/dry/types/default.rb +2 -2
  20. data/lib/dry/types/enum.rb +2 -2
  21. data/lib/dry/types/errors.rb +5 -5
  22. data/lib/dry/types/extensions.rb +4 -0
  23. data/lib/dry/types/extensions/maybe.rb +14 -14
  24. data/lib/dry/types/extensions/monads.rb +29 -0
  25. data/lib/dry/types/hash.rb +3 -2
  26. data/lib/dry/types/lax.rb +2 -5
  27. data/lib/dry/types/meta.rb +3 -3
  28. data/lib/dry/types/module.rb +3 -3
  29. data/lib/dry/types/nominal.rb +1 -1
  30. data/lib/dry/types/params.rb +6 -0
  31. data/lib/dry/types/predicate_inferrer.rb +197 -0
  32. data/lib/dry/types/predicate_registry.rb +34 -0
  33. data/lib/dry/types/primitive_inferrer.rb +97 -0
  34. data/lib/dry/types/printer.rb +7 -3
  35. data/lib/dry/types/result.rb +2 -2
  36. data/lib/dry/types/schema.rb +23 -2
  37. data/lib/dry/types/schema/key.rb +16 -3
  38. data/lib/dry/types/spec/types.rb +14 -1
  39. data/lib/dry/types/sum.rb +5 -5
  40. data/lib/dry/types/version.rb +1 -1
  41. metadata +26 -45
  42. data/.codeclimate.yml +0 -15
  43. data/.gitignore +0 -11
  44. data/.rspec +0 -2
  45. data/.travis.yml +0 -27
  46. data/.yardopts +0 -9
  47. data/CONTRIBUTING.md +0 -29
  48. data/Gemfile +0 -27
  49. data/Rakefile +0 -22
  50. data/benchmarks/hash_schemas.rb +0 -55
  51. data/benchmarks/lax_schema.rb +0 -15
  52. data/benchmarks/profile_invalid_input.rb +0 -15
  53. data/benchmarks/profile_lax_schema_valid.rb +0 -16
  54. data/benchmarks/profile_valid_input.rb +0 -15
  55. data/benchmarks/schema_valid_vs_invalid.rb +0 -21
  56. data/benchmarks/setup.rb +0 -17
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2013-2014 Piotr Solnica
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
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
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
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
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
- [travis]: https://travis-ci.org/dry-rb/dry-types
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-types
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 [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
9
8
 
10
9
  [![Gem Version](https://badge.fury.io/rb/dry-types.svg)][gem]
11
- [![Build Status](https://travis-ci.org/dry-rb/dry-types.svg?branch=master)][travis]
12
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-types/badges/gpa.svg)][codeclimate]
13
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-types/badges/coverage.svg)][codeclimate]
10
+ [![CI Status](https://github.com/dry-rb/dry-types/workflows/ci/badge.svg)][actions]
11
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f2d71613195f4da993acb9ac9d6ea336)][codacy]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/f2d71613195f4da993acb9ac9d6ea336)][codacy]
14
13
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-types.svg?branch=master)][inchpages]
15
14
 
16
15
  ## Links
17
16
 
18
- * [Documentation](http://dry-rb.org/gems/dry-types)
17
+ * [User documentation](http://dry-rb.org/gems/dry-types)
18
+ * [API documentation](http://rubydoc.info/gems/dry-types)
19
19
 
20
- ## Development
20
+ ## Supported Ruby versions
21
21
 
22
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake run_specs` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
+ This library officially supports the following Ruby versions:
23
23
 
24
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+ * MRI >= `2.4`
25
+ * jruby >= `9.2`
25
26
 
26
- ## Contributing
27
+ ## License
27
28
 
28
- Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-types.
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.version = Dry::Types::VERSION.dup
10
- spec.authors = ['Piotr Solnica']
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 = 'Type system for Ruby supporting coercions, constraints and complex types like structs, value objects, enums etc.'
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://github.com/dry-rb/dry-types'
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
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
- # delete this section to allow pushing this gem to any host.
20
- if spec.respond_to?(:metadata)
21
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
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.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - ['bin/console', 'bin/setup']
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
- spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
36
- spec.add_runtime_dependency 'dry-container', '~> 0.3'
37
- spec.add_runtime_dependency 'dry-core', '~> 0.4', '>= 0.4.4'
38
- spec.add_runtime_dependency 'dry-equalizer', '~> 0.2', '>= 0.2.2'
39
- spec.add_runtime_dependency 'dry-inflector', '~> 0.1', '>= 0.1.2'
40
- spec.add_runtime_dependency 'dry-logic', '~> 1.0', '>= 1.0.2'
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 'bundler'
43
- spec.add_development_dependency 'dry-monads', '~> 0.2'
44
- spec.add_development_dependency 'rake', '~> 11.0'
45
- spec.add_development_dependency 'rspec', '~> 3.3'
46
- spec.add_development_dependency 'yard', '~> 0.9.5'
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, { **options, member: member.lax }))
103
+ Lax.new(Member.new(primitive, **options, member: member.lax, meta: meta))
104
104
  end
105
105
 
106
106
  # @see Nominal#to_ast
@@ -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
- self::Array.of(type)
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
- self::Hash.schema(type_map)
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.new(klass).constrained(type: klass)
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.new(value.class).constrained(eql: value)
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.new(object.class).constrained(is: object)
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
- Nominal.new(klass).constructor(cons || block || klass.method(:new))
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
- Nominal.new(klass)
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
- Types['nominal.hash'].map(key_type, value_type)
122
+ Nominal(::Hash).map(key_type, value_type)
109
123
  end
110
124
 
111
125
  # Builds a constrained nominal type accepting any value that
@@ -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
 
@@ -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.merge(meta: meta))
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.merge(meta: meta))
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({**options, fn: fn >> (new_fn || block)})
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({**options, fn: fn << (new_fn || block)})
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.__send__(method, *args, &block)
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