Class: Preserve::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/preserve/callback.rb

Instance Method Summary collapse

Constructor Details

#initialize(source_class, parameter_key, options) ⇒ Callback

Returns a new instance of Callback.



9
10
11
12
13
# File 'lib/preserve/callback.rb', line 9

def initialize(source_class, parameter_key, options)
  @source_class = source_class
  @parameter_key = parameter_key
  @options = options
end

Instance Method Details

#before(controller) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/preserve/callback.rb', line 15

def before(controller)
  @controller = controller

  if parameter_blank?
    parameter_stored? ? restore_parameter : set_default_value
  else
    store_parameter
  end
end