Sha256: f359af384c024db1962e79f43dd9890a78c4a2b6f93cf30482e8e74816b7dba1

Contents?: true

Size: 1018 Bytes

Versions: 4

Compression:

Stored size: 1018 Bytes

Contents

module Ominous
  module ApplicationHelper
    def ominous_warnings
      process_ominous_warnings
      if ominous_warnings_to_show?
        content_tag(
          'div', 
          render(
            :partial => 'ominous/warnings/list',
            :locals => {:warnings => ominous_warning_to_display}
          ), 
          :class => 'ominous_warnings')
      end
    end
    
    def process_ominous_warnings
      Warning.requests.each do |request| 
        ominous_session_store[request.to_sym] = :show unless ominous_session_store[request.to_sym]
      end
      Warning.clear_requests
    end
    
    def ominous_warnings_to_show?
      ominous_session_store.values.include? :show
    end
    
    def ominous_session_store
      session[:ominous_warnings] ||= {}
    end
    
    def ominous_warning_to_display
      warnings = ominous_session_store.keys.collect do |name| 
        Warning.find_by_name(name) if ominous_session_store[name] == :show
      end
      return warnings.compact
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ominous-0.1.3 app/helpers/ominous/application_helper.rb
ominous-0.1.2 app/helpers/ominous/application_helper.rb
ominous-0.1.1 app/helpers/ominous/application_helper.rb
ominous-0.1.0 app/helpers/ominous/application_helper.rb