Class: Dry::Types::Intersection
- Inherits:
-
Object
- Object
- Dry::Types::Intersection
- Includes:
- Composition
- Defined in:
- lib/dry/types/intersection.rb
Overview
Intersection type
Instance Attribute Summary
Attributes included from Composition
Attributes included from Options
Class Method Summary collapse
Instance Method Summary collapse
- #call_safe(input, &block) ⇒ Object private
- #call_unsafe(input) ⇒ Object private
- #primitive?(value) ⇒ Boolean private
- #try(input) ⇒ Object
Methods included from Composition
#constrained?, #default?, #failure, included, #initialize, #name, #optional?, #success, #to_ast, #to_proc
Methods included from Printable
Methods included from Meta
#initialize, #meta, #pristine, #with
Methods included from Options
Methods included from Builder
#&, #>, #constrained, #constrained_type, #constructor, #constructor_type, #default, #enum, #fallback, #lax, #maybe, #optional, #|
Methods included from Type
Class Method Details
.operator ⇒ Object
15 16 17 |
# File 'lib/dry/types/intersection.rb', line 15 def self.operator :& end |
Instance Method Details
#call_safe(input, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/dry/types/intersection.rb', line 33 def call_safe(input, &block) try_sides(input, &block).input end |
#call_unsafe(input) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/dry/types/intersection.rb', line 24 def call_unsafe(input) merge_results(left.call_unsafe(input), right.call_unsafe(input)) end |
#primitive?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/dry/types/intersection.rb', line 55 def primitive?(value) left.primitive?(value) && right.primitive?(value) end |
#try(input) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/dry/types/intersection.rb', line 40 def try(input) try_sides(input) do |failure| if block_given? yield(failure) else failure end end end |