Class: Spider::FlashHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/spiderfw/controller/session/flash_hash.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FlashHash) initialize

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

- (Object) accessed (readonly)

Returns the value of attribute accessed



5
6
7
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 5

def accessed
  @accessed
end

- (Object) active(key) (readonly)

Returns the value of attribute active



5
6
7
8
9
10
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 5

def active(key)
    @active[key] = true
    if (@parent_flash)
        @parent_flash.active(@parent_flash_key)
    end
end

- (Object) parent_flash

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

- (Object) parent_flash_key

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

- (Object) [](key)



21
22
23
24
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 21

def [](key)
    @accessed[key] = true
    super
end

- (Object) []=(key, val)



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

- (Object) delete(key)



43
44
45
46
# File 'lib/spiderfw/controller/session/flash_hash.rb', line 43

def delete(key)
    super
    @sub_flashes.delete(key)
end

- (Object) purge



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

- (Object) reset



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