Class: Padrino::Flash::Storage

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb

Overview

self

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Storage

Returns a new instance of Storage.



18
19
20
21
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 18

def initialize(session=nil)
  @_now  = session || {}
  @_next = {}
end

Instance Method Details

#[](type) ⇒ Object

Since:

  • 0.10.8



33
34
35
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 33

def [](type)
  @_now[type]
end

#[]=(type, message) ⇒ Object

Since:

  • 0.10.8



39
40
41
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 39

def []=(type, message)
  @_next[type] = message
end

#clearObject

Since:

  • 0.10.8



115
116
117
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 115

def clear
  @_now.clear
end

#delete(type) ⇒ Object

Since:

  • 0.10.8



45
46
47
48
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 45

def delete(type)
  @_now.delete(type)
  self
end

#discard(key = nil) ⇒ Object

Since:

  • 0.10.8



104
105
106
107
108
109
110
111
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 104

def discard(key = nil)
  if key
    @_next.delete(key)
  else
    @_next = {}
  end
  self
end

#each(&block) ⇒ Object

Since:

  • 0.10.8



64
65
66
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 64

def each(&block)
  @_now.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)

Since:

  • 0.10.8



121
122
123
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 121

def empty?
  @_now.empty?
end

#errorObject

Since:

  • 0.10.8



150
151
152
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 150

def error
  self[:error]
end

#error=(message) ⇒ Object

Since:

  • 0.10.8



144
145
146
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 144

def error=(message)
  self[:error] = message
end

#keep(key = nil) ⇒ Object

Since:

  • 0.10.8



93
94
95
96
97
98
99
100
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 93

def keep(key = nil)
  if key
    @_next[key] = @_now[key]
  else
    @_next.merge!(@_now)
  end
  self
end

#key?(type) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.10.8



58
59
60
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 58

def key?(type)
  @_now.key?(type)
end

#keysObject

Since:

  • 0.10.8



52
53
54
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 52

def keys
  @_now.keys
end

#lengthObject Also known as: size



131
132
133
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 131

def length
  @_now.length
end

#nextObject



27
28
29
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 27

def next
  @_next
end

#noticeObject

Since:

  • 0.10.8



162
163
164
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 162

def notice
  self[:notice]
end

#notice=(message) ⇒ Object

Since:

  • 0.10.8



156
157
158
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 156

def notice=(message)
  self[:notice] = message
end

#nowObject



23
24
25
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 23

def now
  @_now
end

#replace(hash) ⇒ Object

Since:

  • 0.10.8



70
71
72
73
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 70

def replace(hash)
  @_now.replace(hash)
  self
end

#successObject

Since:

  • 0.10.8



174
175
176
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 174

def success
  self[:success]
end

#success=(message) ⇒ Object

Since:

  • 0.10.8



168
169
170
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 168

def success=(message)
  self[:success] = message
end

#sweepObject

Since:

  • 0.10.8



85
86
87
88
89
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 85

def sweep
  @_now.replace(@_next)
  @_next = {}
  self
end

#to_hashObject

Since:

  • 0.10.8



127
128
129
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 127

def to_hash
  @_now.dup
end

#to_sObject

Since:

  • 0.10.8



138
139
140
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 138

def to_s
  @_now.to_s
end

#update(hash) ⇒ Object Also known as: merge!

Since:

  • 0.10.8



77
78
79
80
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 77

def update(hash)
  @_now.update(hash)
  self
end