Add a vote candidate before voting
187641
public function addCandidate ($candidate_id = null) : Candidate
    {
        // only if the vote has not started
        if ( $this->_State > 1 ) :
            throw new CondorcetException(2);
        endif;

        // Filter
        if ( is_bool($candidate_id) || is_array($candidate_id) || (is_object($candidate_id) && !($candidate_id instanceof Candidate)) ) :
            throw new CondorcetException(1, $candidate_id);
        endif;


        // Process
        if ( empty($candidate_id) ) :
            while ( !$this->canAddCandidate($this->_i_CandidateId) ) :
                $this->_i_CandidateId++;
            endwhile;

            $newCandidate = new Candidate($this->_i_CandidateId);
        else : // Try to add the candidate_id
            $newCandidate = ($candidate_id instanceof Candidate) ? $candidate_id : new Candidate ((string) $candidate_id);

            if ( !$this->canAddCandidate($newCandidate) ) :
                throw new CondorcetException(3,$candidate_id);
            endif;
        endif;

        // Register it
        $this->_Candidates[] = $newCandidate;

        // Linking
        $newCandidate->registerLink($this);

        // Disallow other candidate object name matching 
        $newCandidate->setProvisionalState(false);

        return $newCandidate;
    }
821303
def vote(value, voted_by)
      mark = Vote.new(value: value, voted_by_id: voted_by.id, voter_type: voted_by.class.name)
      add_vote_mark(mark)
    end
415773
public function initDefaultMentions(): Ballot{
        $this->mentions=[new Mention("Excellent"),new Mention("Good"),new Mention("Pretty good"),new Mention("Fair"),new Mention("Insufficient"),new Mention("To Reject")];
        return $this;
    }
75944
public function addVotable(DownloaderVotableInterface $votable, $prepend = false)
    {
        if ($prepend) {
            array_unshift($this->votables, $votable);
        } else {
            $this->votables[] = $votable;
        }
    }
966094
def upvote
      begin
        client.post("/cards/#{id}/membersVoted", {
          value: me.id
        })
      rescue Trello::Error => e
        fail e unless e.message =~ /has already voted/i
      end

      self
    end
750321
def get_or_create_votes(self, row, division, candidate_election):
        
        vote.Votes.objects.get_or_create(
            division=division,
            count=row["votecount"],
            pct=row["votepct"],
            winning=row["winner"],
            runoff=row["runoff"],
            candidate_election=candidate_election,
        )
288216
def get_candidate_votes(self, candidate):
        
        candidate_election = CandidateElection.objects.get(
            candidate=candidate, election=self
        )

        return candidate_election.votes.all()
772785
def up_vote(votable)
      is_votable?(votable)
      
      vote = get_vote(votable)
      
      if vote
        if vote.up_vote
          raise Exceptions::AlreadyVotedError.new(true)
        else
          vote.up_vote = true
          votable.down_votes -= 1
          self.down_votes -= 1 if has_attribute?(:down_votes)
        end
      else
        vote = Vote.create(:votable => votable, :voter => self, :up_vote => true)
      end
      
      votable.up_votes += 1
      self.up_votes += 1 if has_attribute?(:up_votes)  
      
      Vote.transaction do
        save
        votable.save
        vote.save
      end
      
      true
    end
1161529
public VoteRequest toCandidate() {
        role = RaftRole.CANDIDATE;
        preCandidateState = null;
        leaderState = null;
        candidateState = new CandidateState(majority());
        candidateState.grantVote(localEndpoint);
        persistVote(incrementTerm(), localEndpoint);

        return new VoteRequest(localEndpoint, term, log.lastLogOrSnapshotTerm(), log.lastLogOrSnapshotIndex());
    }
698414
def vote(session, nick, pid, response):
    """"""
    if not response:
        return "You have to vote something!"
    if response == "n" or response == "nay":
        response = "no"
    elif response == "y" or response == "aye":
        response = "yes"
    poll = get_open_poll(session, pid)
    if poll is None:
        return "That poll doesn't exist or isn't active. Use !poll list to see valid polls"
    old_vote = get_response(session, pid, nick)
    if old_vote is None:
        session.add(Poll_responses(pid=pid, response=response, voter=nick))
        return "%s voted %s." % (nick, response)
    else:
        if response == old_vote.response:
            return "You've already voted %s." % response
        else:
            msg = "%s changed their vote from %s to %s." % (nick, old_vote.response, response)
            old_vote.response = response
            return msg
1020698
def registerPolling(self, fd, options = POLLING_IN|POLLING_OUT, daemon = False):
        '''
        
        '''
        self.polling.register(fd, options, daemon)
166980
def up_vote!(votable)
      begin
        up_vote(votable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
473668
public void add(final String string) {
    checkNotNull(string);
    candidates.put(string, candidate(string));
  }
678719
def vote_up_idea(self, *args, **kwargs):
        
        kwargs.update({'headers': {'content-type':'application/json'}})
        return bind_api(
            api=self,
            path='/ideas/{ideaId}/vote/up',
            method='POST',
            payload_type='vote',
            allowed_param=['ideaId'],
            post_param=['myVote']
        )(*args, **kwargs)
654257
def insert(self, index, value):
        """"""
        self.check(value)
        self._user_list.insert(index, value)
494467
def add_callback(self, events, callback):
        """"""
        if self._poll is None:
            raise RuntimeError('poll instance is closed')
        if events & ~(READABLE|WRITABLE):
            raise ValueError('illegal event mask: {}'.format(events))
        if events & READABLE:
            self._readers += 1
        if events & WRITABLE:
            self._writers += 1
        handle = add_callback(self, callback, events)
        self._sync()
        return handle
771056
public function preAdd(Event $e)
    {
        $form = $e->getParam('form');
        /* @var $inputFilter \UthandoUser\InputFilter\UserInputFilter */
        $inputFilter = $form->getInputFilter();
        $inputFilter->addEmailNoRecordExists();
    }