Class: Radical::Flash::FlashHash

Inherits:
Object
  • Object
show all
Defined in:
lib/radical/flash.rb

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ FlashHash

Returns a new instance of FlashHash.

Raises:



11
12
13
14
15
# File 'lib/radical/flash.rb', line 11

def initialize(session)
  raise SessionUnavailable, 'No session variable found. Requires Rack::Session' unless session

  @session = session
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/radical/flash.rb', line 17

def [](key)
  hash[key] ||= session.delete(key)
end

#[]=(key, value) ⇒ Object



21
22
23
# File 'lib/radical/flash.rb', line 21

def []=(key, value)
  hash[key] = session[key] = value
end

#clear!Object



29
30
31
32
# File 'lib/radical/flash.rb', line 29

def clear!
  @flagged.each { |k| session.delete(k) }
  @flagged.clear
end

#mark!Object



25
26
27
# File 'lib/radical/flash.rb', line 25

def mark!
  @flagged = session.keys
end