Class: Spider::FlashHash
- Defined in:
- lib/spiderfw/controller/session/flash_hash.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#accessed ⇒ Object
readonly
Returns the value of attribute accessed.
-
#active(key) ⇒ Object
readonly
Returns the value of attribute active.
-
#parent_flash ⇒ Object
Returns the value of attribute parent_flash.
-
#parent_flash_key ⇒ Object
Returns the value of attribute parent_flash_key.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize ⇒ FlashHash
constructor
A new instance of FlashHash.
- #purge ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ FlashHash
Returns a new instance of FlashHash.
7 8 9 10 11 12 13 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 7 def initialize super @sub_flashes = {} @parent_flash = nil @parent_flash_key = nil reset end |
Instance Attribute Details
#accessed ⇒ Object (readonly)
Returns the value of attribute accessed.
5 6 7 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 5 def accessed @accessed end |
#active(key) ⇒ Object (readonly)
Returns the value of attribute active.
5 6 7 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 5 def active @active end |
#parent_flash ⇒ Object
Returns the value of attribute parent_flash.
4 5 6 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 4 def parent_flash @parent_flash end |
#parent_flash_key ⇒ Object
Returns the value of attribute parent_flash_key.
4 5 6 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 4 def parent_flash_key @parent_flash_key end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 24 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 21 def [](key) @accessed[key] = true super end |
#[]=(key, val) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 26 def []=(key, val) super active(key) if (val.is_a?(FlashHash)) val.parent_flash = self val.parent_flash_key = key @sub_flashes[key] = val end end |
#delete(key) ⇒ Object
43 44 45 46 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 43 def delete(key) super @sub_flashes.delete(key) end |
#purge ⇒ Object
48 49 50 51 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 48 def purge self.delete_if{ |k, v| @accessed[k] && !@active[k] } @sub_flashes.each{ |k, f| f.purge } end |
#reset ⇒ Object
15 16 17 18 19 |
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 15 def reset @active = {} @accessed = {} @sub_flashes.each{ |k, f| f.reset } end |