Logic for the :copy_on_change parameter
# File lib/bindata/choice.rb, line 169 def copy_previous_value(obj) current_selection = selection prev = get_previous_choice(current_selection) obj.assign(prev) unless prev.nil? remember_current_selection(current_selection) end
# File lib/bindata/choice.rb, line 163 def current_choice obj = super copy_previous_value(obj) obj end
# File lib/bindata/choice.rb, line 176 def get_previous_choice(selection) if @last_selection && selection != @last_selection @choices[@last_selection] end end
# File lib/bindata/choice.rb, line 182 def remember_current_selection(selection) @last_selection = selection end