Module: Sinatra::Messages::Helpers
- Defined in:
- lib/sinatra/messages.rb
Instance Method Summary collapse
Instance Method Details
#add_message(mensaje, type = :info) ⇒ Object
31 32 33 34 |
# File 'lib/sinatra/messages.rb', line 31 def (mensaje, type=:info) session['messages']||=[] session['messages'].push([mensaje,type]) end |
#add_result(result) ⇒ Object
35 36 37 38 39 |
# File 'lib/sinatra/messages.rb', line 35 def add_result(result) result.events.each do |event| (event[:message], event[:type]) end end |
#print_messages ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sinatra/messages.rb', line 41 def if session['messages'] #$log.info(session['messages']) out=session['messages'].map {|men,type| "<div class='alert alert-#{type.to_s} #{type.to_s=='error' ? 'alert-danger' : ''}' role='alert'>#{men}</div>\n" } session.delete("messages") out.join() else "" end end |