Sha256: 53ffa8af9eecc880f2ef7213fa376ebce438e7ca42dddd8d527ec3d950f9c344

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

module MakeVoteable
  module Exceptions
    class AlreadyVotedError < StandardError
      attr_reader :up_vote

      def initialize(up_vote)
        @up_vote = up_vote
      end
      
      def message
        if @up_vote
          vote = "up voted"
        else
          vote = "down voted"
        end

        "The voteable was already #{vote} by the voter."
      end
    end

    class NotVotedError < StandardError
      def message
        "The voteable was not voted by the voter."
      end
    end

    class InvalidVoteableError < StandardError
      def message
        "Invalid voteable."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
make_voteable-0.0.2 lib/make_voteable/exceptions.rb