mangrove 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/docs/Mangrove/ControlFlow/ControlSignal.html +1 -1
- data/docs/Mangrove/ControlFlow/Handler/ClassMethods.html +1 -1
- data/docs/Mangrove/ControlFlow/Handler.html +1 -1
- data/docs/Mangrove/ControlFlow/Rewriter.html +1 -1
- data/docs/Mangrove/ControlFlow.html +5 -16
- data/docs/Mangrove/Option/ControlSignal.html +1 -1
- data/docs/Mangrove/Option/None.html +121 -32
- data/docs/Mangrove/Option/Some.html +90 -1
- data/docs/Mangrove/Option.html +106 -17
- data/docs/Mangrove/Result/ControlSignal.html +1 -1
- data/docs/Mangrove/Result/Err.html +1 -1
- data/docs/Mangrove/Result/Ok.html +1 -1
- data/docs/Mangrove/Result.html +1 -1
- data/docs/Mangrove.html +3 -3
- data/docs/_index.html +1 -26
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +3 -3
- data/docs/index.html +3 -3
- data/docs/method_list.html +89 -105
- data/docs/top-level-namespace.html +1 -1
- data/lib/mangrove/control_flow/rewriter.rb +4 -1
- data/lib/mangrove/option.rb +13 -0
- data/lib/mangrove/version.rb +1 -1
- data/lib/mangrove.rb +0 -1
- metadata +2 -3
- data/lib/mangrove/control_flow.rb +0 -84
@@ -1,84 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative "control_flow/control_signal"
|
5
|
-
require_relative "control_flow/rewriter"
|
6
|
-
|
7
|
-
module Mangrove
|
8
|
-
# Mangrove::ControlFlow
|
9
|
-
module ControlFlow
|
10
|
-
# Mangrove::ControlFlow::Handler
|
11
|
-
module Handler
|
12
|
-
extend T::Sig
|
13
|
-
extend T::Helpers
|
14
|
-
|
15
|
-
interface!
|
16
|
-
|
17
|
-
# Mangrove::ControlFlow::ClassMethods
|
18
|
-
module ClassMethods
|
19
|
-
extend T::Sig
|
20
|
-
extend T::Helpers
|
21
|
-
|
22
|
-
abstract!
|
23
|
-
|
24
|
-
def singleton_method_added(method_name)
|
25
|
-
T.bind(self, T.all(ClassMethods, Module))
|
26
|
-
|
27
|
-
super
|
28
|
-
|
29
|
-
unless @__inside_mangrove_control_flow
|
30
|
-
original_method = method(method_name)
|
31
|
-
|
32
|
-
wrap_original_method_to_handle_flow_control_exception(original_method)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def method_added(method_name)
|
37
|
-
T.bind(self, T.all(ClassMethods, Module))
|
38
|
-
|
39
|
-
super
|
40
|
-
|
41
|
-
unless @__inside_mangrove_control_flow
|
42
|
-
original_method = instance_method(method_name)
|
43
|
-
|
44
|
-
wrap_original_method_to_handle_flow_control_exception(original_method)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
sig { params(signal: ControlFlow::ControlSignal).void }
|
49
|
-
def handle_flow_control_exception(signal)
|
50
|
-
signal.inner_value
|
51
|
-
end
|
52
|
-
|
53
|
-
sig { params(original_method: T.any(Method, UnboundMethod)).void }
|
54
|
-
def wrap_original_method_to_handle_flow_control_exception(original_method)
|
55
|
-
T.bind(self, T.class_of(Kernel))
|
56
|
-
|
57
|
-
@__mangrove_flow_controlled_method_names ||= T.let(
|
58
|
-
{},
|
59
|
-
T.nilable(T::Hash[Symbol, T::Set[Symbol]])
|
60
|
-
)
|
61
|
-
|
62
|
-
@__mangrove_flow_controlled_method_names[name.to_s.intern] ||= T.let(Set.new, T::Set[Symbol])
|
63
|
-
|
64
|
-
return if T.cast(@__mangrove_flow_controlled_method_names[name.to_s.intern], T::Set[Symbol]).include?(original_method.name)
|
65
|
-
|
66
|
-
begin
|
67
|
-
@__inside_mangrove_control_flow = T.let(true, T.nilable(T::Boolean))
|
68
|
-
|
69
|
-
class_eval(Mangrove::ControlFlow.impl!(original_method))
|
70
|
-
ensure
|
71
|
-
@__inside_mangrove_control_flow = false
|
72
|
-
end
|
73
|
-
|
74
|
-
T.cast(@__mangrove_flow_controlled_method_names[name.to_s.intern], T::Set[Symbol]) << original_method.name
|
75
|
-
end
|
76
|
-
|
77
|
-
sig { returns(T.nilable(T::Hash[Symbol, T::Set[Symbol]])) }
|
78
|
-
attr_reader :__mangrove_flow_controlled_method_names
|
79
|
-
end
|
80
|
-
|
81
|
-
mixes_in_class_methods(ClassMethods)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|