Class: Effective::Ballot

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/ballot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_stepObject

Returns the value of attribute current_step.



4
5
6
# File 'app/models/effective/ballot.rb', line 4

def current_step
  @current_step
end

#current_userObject

Returns the value of attribute current_user.



3
4
5
# File 'app/models/effective/ballot.rb', line 3

def current_user
  @current_user
end

Instance Method Details

#ballot_response(poll_question) ⇒ Object

Find or build



55
56
57
58
# File 'app/models/effective/ballot.rb', line 55

def ballot_response(poll_question)
  ballot_response = ballot_responses.find { |br| br.poll_question_id == poll_question.id }
  ballot_response ||= ballot_responses.build(poll: poll_question.poll, poll_question: poll_question)
end

#completed?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'app/models/effective/ballot.rb', line 68

def completed?
  completed_at.present?
end

#submit!Object

This is the review step where they click Submit Ballot



61
62
63
64
65
66
# File 'app/models/effective/ballot.rb', line 61

def submit!
  wizard_steps[:complete] ||= Time.zone.now
  self.completed_at ||= Time.zone.now

  save!
end

#to_sObject



50
51
52
# File 'app/models/effective/ballot.rb', line 50

def to_s
  'ballot'
end