Class: Padrino::Flash::Storage

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

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Storage

Returns a new instance of Storage.



17
18
19
20
# File 'lib/padrino-core/application/flash.rb', line 17

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

Instance Method Details

#[](type) ⇒ Object

Since:

  • 0.10.8



32
33
34
# File 'lib/padrino-core/application/flash.rb', line 32

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

#[]=(type, message) ⇒ Object

Since:

  • 0.10.8



38
39
40
# File 'lib/padrino-core/application/flash.rb', line 38

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

#clearObject

Since:

  • 0.10.8



114
115
116
# File 'lib/padrino-core/application/flash.rb', line 114

def clear
  @_now.clear
end

#delete(type) ⇒ Object

Since:

  • 0.10.8



44
45
46
47
# File 'lib/padrino-core/application/flash.rb', line 44

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

#discard(key = nil) ⇒ Object

Since:

  • 0.10.8



103
104
105
106
107
108
109
110
# File 'lib/padrino-core/application/flash.rb', line 103

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

#each(&block) ⇒ Object

Since:

  • 0.10.8



63
64
65
# File 'lib/padrino-core/application/flash.rb', line 63

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

#empty?Boolean

Returns:

  • (Boolean)

Since:

  • 0.10.8



120
121
122
# File 'lib/padrino-core/application/flash.rb', line 120

def empty?
  @_now.empty?
end

#errorObject

Since:

  • 0.10.8



149
150
151
# File 'lib/padrino-core/application/flash.rb', line 149

def error
  self[:error]
end

#error=(message) ⇒ Object

Since:

  • 0.10.8



143
144
145
# File 'lib/padrino-core/application/flash.rb', line 143

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

#keep(key = nil) ⇒ Object

Since:

  • 0.10.8



92
93
94
95
96
97
98
99
# File 'lib/padrino-core/application/flash.rb', line 92

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



57
58
59
# File 'lib/padrino-core/application/flash.rb', line 57

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

#keysObject

Since:

  • 0.10.8



51
52
53
# File 'lib/padrino-core/application/flash.rb', line 51

def keys
  @_now.keys
end

#lengthObject Also known as: size



130
131
132
# File 'lib/padrino-core/application/flash.rb', line 130

def length
  @_now.length
end

#nextObject



26
27
28
# File 'lib/padrino-core/application/flash.rb', line 26

def next
  @_next
end

#noticeObject

Since:

  • 0.10.8



161
162
163
# File 'lib/padrino-core/application/flash.rb', line 161

def notice
  self[:notice]
end

#notice=(message) ⇒ Object

Since:

  • 0.10.8



155
156
157
# File 'lib/padrino-core/application/flash.rb', line 155

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

#nowObject



22
23
24
# File 'lib/padrino-core/application/flash.rb', line 22

def now
  @_now
end

#replace(hash) ⇒ Object

Since:

  • 0.10.8



69
70
71
72
# File 'lib/padrino-core/application/flash.rb', line 69

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

#successObject

Since:

  • 0.10.8



173
174
175
# File 'lib/padrino-core/application/flash.rb', line 173

def success
  self[:success]
end

#success=(message) ⇒ Object

Since:

  • 0.10.8



167
168
169
# File 'lib/padrino-core/application/flash.rb', line 167

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

#sweepObject

Since:

  • 0.10.8



84
85
86
87
88
# File 'lib/padrino-core/application/flash.rb', line 84

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

#to_hashObject

Since:

  • 0.10.8



126
127
128
# File 'lib/padrino-core/application/flash.rb', line 126

def to_hash
  @_now.dup
end

#to_sObject

Since:

  • 0.10.8



137
138
139
# File 'lib/padrino-core/application/flash.rb', line 137

def to_s
  @_now.to_s
end

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

Since:

  • 0.10.8



76
77
78
79
# File 'lib/padrino-core/application/flash.rb', line 76

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