Class: Mengpaneel::Delayer

Inherits:
Object
  • Object
show all
Defined in:
lib/mengpaneel/delayer.rb

Constant Summary collapse

SESSION_KEY =
"mengpaneel_delayed_calls".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller = nil) ⇒ Delayer

Returns a new instance of Delayer.


7
8
9
# File 'lib/mengpaneel/delayer.rb', line 7

def initialize(controller = nil)
  @controller = controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller


5
6
7
# File 'lib/mengpaneel/delayer.rb', line 5

def controller
  @controller
end

Instance Method Details

#loadObject


11
12
13
# File 'lib/mengpaneel/delayer.rb', line 11

def load
  (controller.session[SESSION_KEY] || {}).with_indifferent_access
end

#load!Object


15
16
17
18
19
# File 'lib/mengpaneel/delayer.rb', line 15

def load!
  calls = load
  controller.session.delete(SESSION_KEY)
  calls
end

#save(all_calls) ⇒ Object


21
22
23
# File 'lib/mengpaneel/delayer.rb', line 21

def save(all_calls)
  controller.session[SESSION_KEY] = all_calls
end