Sha256: d5a6d8fba1c719b1365e0eb5912fd8cd64f6f52b3a160bc18d3c827f8b5cac54

Contents?: true

Size: 847 Bytes

Versions: 3

Compression:

Stored size: 847 Bytes

Contents

module ActionController
  class Base < Metal

    def self.disclaimer(document_name, options = {})
      before_filter(options) {|c| c.redirect_to_disclaimer(document_name)}
    end

    def redirect_to_disclaimer(document_name)
      @disclaimer_document_name = document_name.to_sym
      unless disclaimer_has_been_accepted
        store_disclaimer_return_location
        document = Disclaimer::Document.find_by_name(@disclaimer_document_name)
        redirect_to disclaimer.document_path(document)
      end
    end

    def disclaimer_has_been_accepted
      session[:disclaimer] && session[:disclaimer][@disclaimer_document_name] == Disclaimer::ACCEPTED
    end

    def store_disclaimer_return_location
      session[:disclaimer] ||= {}
      session[:disclaimer][@disclaimer_document_name] = url_for(request.parameters)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
disclaimer-0.0.3 lib/rails/actionpack/lib/action_controller/base.rb
disclaimer-0.0.2 lib/rails/actionpack/lib/action_controller/base.rb
disclaimer-0.0.1 lib/rails/actionpack/lib/action_controller/base.rb