6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sbmt/strangler/configurable.rb', line 6
def option(*hash)
case hash
in [*attributes, Hash => options]
in [*attributes]
options = {}
end
attributes.each do |attribute|
define_method :"#{attribute}=" do |value|
instance_variable_set(:"@#{attribute}", value)
end
define_method attribute.to_s do
value = instance_variable_get(:"@#{attribute}")
return value if value
if options[:default_from]
value = send(options[:default_from])&.public_send(attribute)
end
value || options[:default]
end
end
end
|