Class: PollParticipation

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Diaspora::Federated::Base, Diaspora::Guid, Diaspora::Relayable
Defined in:
app/models/poll_participation.rb

Defined Under Namespace

Classes: Generator

Instance Method Summary collapse

Methods included from Diaspora::Relayable

#after_receive, #author_is_not_ignored, included, #initialize_signatures, #parent_guid, #parent_guid=, #receive, #relayable?, #signature_valid?, #subscribers, #verify_parent_author_signature

Methods included from Diaspora::Encryptable

#sign_with_key, #signable_accessors, #signable_string, #verify_signature

Methods included from Diaspora::Guid

included, #set_guid

Methods included from Diaspora::Federated::Base

included

Instance Method Details

#diaspora_handleObject


35
36
37
# File 'app/models/poll_participation.rb', line 35

def diaspora_handle
  self.author.diaspora_handle
end

#diaspora_handle=(nh) ⇒ Object


39
40
41
# File 'app/models/poll_participation.rb', line 39

def diaspora_handle= nh
  self.author = Webfinger.new(nh).fetch
end

#not_already_participatedObject


43
44
45
46
47
48
49
50
# File 'app/models/poll_participation.rb', line 43

def not_already_participated
  return if poll.nil?

  other_participations = PollParticipation.where(author_id: self.author.id, poll_id: self.poll.id).to_a-[self]
  if other_participations.present?
    self.errors.add(:poll, I18n.t("activerecord.errors.models.poll_participation.attributes.poll.already_participated"))
  end
end

#parentObject


19
20
21
# File 'app/models/poll_participation.rb', line 19

def parent
  self.poll
end

#parent=(parent) ⇒ Object


31
32
33
# File 'app/models/poll_participation.rb', line 31

def parent= parent
  self.poll = parent
end

#parent_classObject


15
16
17
# File 'app/models/poll_participation.rb', line 15

def parent_class
  Poll
end

#poll_answer_guidObject


23
24
25
# File 'app/models/poll_participation.rb', line 23

def poll_answer_guid
  poll_answer.guid
end

#poll_answer_guid=(new_poll_answer_guid) ⇒ Object


27
28
29
# File 'app/models/poll_participation.rb', line 27

def poll_answer_guid= new_poll_answer_guid
  self.poll_answer = PollAnswer.where(:guid => new_poll_answer_guid).first
end