Module: BinData::CopyOnChangePlugin
- Defined in:
- lib/bindata/choice.rb
Overview
Logic for the :copy_on_change parameter
Instance Method Summary collapse
- #copy_previous_value(obj) ⇒ Object
- #current_choice ⇒ Object
- #get_previous_choice(selection) ⇒ Object
- #remember_current_selection(selection) ⇒ Object
Instance Method Details
#copy_previous_value(obj) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/bindata/choice.rb', line 189 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 |
#current_choice ⇒ Object
183 184 185 186 187 |
# File 'lib/bindata/choice.rb', line 183 def current_choice obj = super copy_previous_value(obj) obj end |
#get_previous_choice(selection) ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/bindata/choice.rb', line 196 def get_previous_choice(selection) if selection != @last_selection and @last_selection != nil @choices[@last_selection] else nil end end |
#remember_current_selection(selection) ⇒ Object
204 205 206 |
# File 'lib/bindata/choice.rb', line 204 def remember_current_selection(selection) @last_selection = selection end |