Sha256: 598927734ec4f5c6f7584c25f41cd654e40318afca48db39739f6b87ccf720ec

Contents?: true

Size: 1.25 KB

Versions: 11

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Cmor
  module Legal
    module Frontend
      class CookiePreferencesController < Cmor::Legal::Frontend::Configuration.base_controller.constantize
        if respond_to?(:before_action)
          before_action :initialize_resource, only: [:edit, :update]
        else
          before_filter :initialize_resource, only: [:edit, :update]
        end

        def edit
        end

        def update
          respond_to do |format|
            if @resource.update_attributes(permitted_params)
              format.html { redirect_to((request.referer || url_for(action: "edit")), notice: t(".success")) }
            else
              format.html { render :edit }
            end
          end
        end

        private
          def permitted_params
            if params.is_a?(ActiveSupport::HashWithIndifferentAccess)
              params[:cookie_preferences]
            else
              params.fetch(:cookie_preferences, {}).permit(@resource.cookies.map(&:identifier))
            end
          end

          def initialize_resource
            @resource = ::Cmor::Legal::CookiePreferences.new(cookie_store: ::Cmor::Legal::CookieStore.new(send(::Cmor::Legal::Configuration.cookie_storage)))
          end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cmor_legal_frontend-0.0.58.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.57.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.56.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.55.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.54.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.53.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.52.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.51.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.50.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.49.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb
cmor_legal_frontend-0.0.48.pre app/controllers/cmor/legal/frontend/cookie_preferences_controller.rb