module AudioFeedManager::GetterSetterMethod
Public Instance Methods
get_set(name, &default)
click to toggle source
# 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