9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/toolrack/block_params_utils.rb', line 9
def value_from_block(blockKey, defValue, opts = { }, &block)
if block
blockParams = nil
if not_empty?(opts)
blockParams = opts[:blockArgs]
end
value = nil
if blockParams.nil?
value = block.call(blockKey)
else
if blockParams.is_a?(Array)
value = block.call(blockKey, *blockParams)
else
value = block.call(blockKey, blockParams)
end
end
block.call(:inspect_given_value, blockKey, opts, value)
value = defValue if is_empty?(value)
value
else
defValue
end
end
|