Class: PollAnswer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PollAnswer
- Includes:
- E9Polls::Model
- Defined in:
- app/models/poll_answer.rb
Instance Method Summary collapse
Instance Method Details
#as_json(options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/models/poll_answer.rb', line 5 def as_json(={}) {}.tap do |hash| hash[:value] = self.value hash[:votes] = self.votes hash[:percentage] = self.percentage end end |
#percentage ⇒ Object
17 18 19 |
# File 'app/models/poll_answer.rb', line 17 def percentage poll.percentage_for(self) end |
#vote! ⇒ Object
13 14 15 |
# File 'app/models/poll_answer.rb', line 13 def vote! increment!(:votes) end |