@@ -10,6 +10,7 @@ module Execution
10
10
# This is an itty-bitty promise-like object, with key differences:
11
11
# - It has only two states, not-resolved and resolved
12
12
# - It has no error-catching functionality
13
+ # @api private
13
14
class Lazy
14
15
# Traverse `val`, lazily resolving any values along the way
15
16
# @param val [Object] A data structure containing mixed plain values and `Lazy` instances
@@ -19,28 +20,17 @@ def self.resolve(val)
19
20
end
20
21
21
22
# Create a {Lazy} which will get its inner value by calling the block
22
- # @param target [Object]
23
- # @param method_name [Symbol]
24
23
# @param get_value_func [Proc] a block to get the inner value (later)
25
- def initialize ( target = nil , method_name = nil , &get_value_func )
26
- if block_given?
27
- @get_value_func = get_value_func
28
- else
29
- @target = target
30
- @method_name = method_name
31
- end
24
+ def initialize ( &get_value_func )
25
+ @get_value_func = get_value_func
32
26
@resolved = false
33
27
end
34
28
35
29
# @return [Object] The wrapped value, calling the lazy block if necessary
36
30
def value
37
31
if !@resolved
38
32
@resolved = true
39
- if @get_value_func
40
- @value = @get_value_func . call
41
- else
42
- @value = @target . public_send ( @method_name )
43
- end
33
+ @value = @get_value_func . call
44
34
end
45
35
@value
46
36
rescue GraphQL ::ExecutionError => err
0 commit comments