Class: Lux::Response::Flash
Class Method Summary collapse
-
.add_type(name) ⇒ Object
flash.info ‘messsage …’ flash.info = ‘messsage …’.
Instance Method Summary collapse
- #clear ⇒ Object
-
#clear_for_js ⇒ Object
clears white space, replaces quotes.
-
#initialize(h = nil) ⇒ Flash
constructor
A new instance of Flash.
- #to_h ⇒ Object
Constructor Details
#initialize(h = nil) ⇒ Flash
Returns a new instance of Flash.
18 19 20 |
# File 'lib/lux/response/lib/flash.rb', line 18 def initialize h=nil @msg = h || {} end |
Class Method Details
.add_type(name) ⇒ Object
flash.info ‘messsage …’ flash.info = ‘messsage …’
7 8 9 10 |
# File 'lib/lux/response/lib/flash.rb', line 7 def self.add_type name define_method(name) { || add name, } eval "alias #{name}= #{name}" end |
Instance Method Details
#clear ⇒ Object
22 23 24 |
# File 'lib/lux/response/lib/flash.rb', line 22 def clear to_h.tap { @msg = {} } end |
#clear_for_js ⇒ Object
clears white space, replaces quotes
31 32 33 34 35 36 37 |
# File 'lib/lux/response/lib/flash.rb', line 31 def clear_for_js {}.tap do |msg| clear.each do |k, v| msg[k] = v.join(', ').gsub(/\s+/, ' ') end end end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/lux/response/lib/flash.rb', line 26 def to_h @msg end |