3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/audio_feed_manager/support/getter_setter_method.rb', line 3
def get_set(name, &default)
define_method name do |value = :no_value_given|
default ||= ->(){}
inst_variable_name = "@#{name}"
instance_variable_set(inst_variable_name, value) if value != :no_value_given
if !instance_variable_defined?(inst_variable_name) && value == :no_value_given
instance_variable_set(inst_variable_name, instance_exec(&default))
end
instance_variable_get(inst_variable_name)
end
end
|