Sha256: e6e2b867645c6ecb1e06a4e2df69f5c1e6be56fcf2e08449042b79d392f005ef

Contents?: true

Size: 714 Bytes

Versions: 10

Compression:

Stored size: 714 Bytes

Contents

module VotesControllerBaseClass
  extend ActiveSupport::Concern
  
  included do
    controller do
      rescue_from Neutral::Errors::RequireLogin, with: :require_login
      rescue_from Neutral::Errors::CannotChange, with: :cannot_change
      rescue_from Neutral::Errors::DuplicateVote, with: :duplicate

      def current_voter
        send Neutral.config.current_voter_method
      end

      private
      def require_login
        render 'neutral/votes/errors/require_login', status: 401
      end

      def cannot_change
        render 'neutral/votes/errors/cannot_change', status: 403
      end

      def duplicate
        render 'neutral/votes/errors/duplicate', status: 409
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neutral-0.0.10 spec/support/votes_controller_base_class.rb
neutral-0.0.9 spec/support/votes_controller_base_class.rb
neutral-0.0.8 spec/support/votes_controller_base_class.rb
neutral-0.0.7 spec/support/votes_controller_base_class.rb
neutral-0.0.6 spec/support/votes_controller_base_class.rb
neutral-0.0.5 spec/support/votes_controller_base_class.rb
neutral-0.0.4 spec/support/votes_controller_base_class.rb
neutral-0.0.3 spec/support/votes_controller_base_class.rb
neutral-0.0.2 spec/support/votes_controller_base_class.rb
neutral-0.0.1 spec/support/votes_controller_base_class.rb