Module: Diaspora::Federation::Mappings

Defined in:
lib/diaspora/federation/mappings.rb

Class Method Summary collapse

Class Method Details

.builder_for(diaspora_entity) ⇒ Object

used in Diaspora::Federation::Entities


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/diaspora/federation/mappings.rb', line 28

def self.builder_for(diaspora_entity)
  case diaspora_entity
  when AccountMigration  then :account_migration
  when AccountDeletion   then :account_deletion
  when Block             then :block
  when Comment           then :comment
  when Contact           then :contact
  when Conversation      then :conversation
  when Like              then :like
  when Message           then :message
  when Participation     then :participation
  when Photo             then :photo
  when PollParticipation then :poll_participation
  when Profile           then :profile
  when Reshare           then :reshare
  when Retraction        then :retraction
  when ContactRetraction then :retraction
  when StatusMessage     then :status_message
  else not_found(diaspora_entity.class)
  end
end

.entity_name_for(model) ⇒ Object


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/diaspora/federation/mappings.rb', line 67

def self.entity_name_for(model)
  case model
  when Comment           then "Comment"
  when Like              then "Like"
  when Participation     then "Participation"
  when PollParticipation then "PollParticipation"
  when Photo             then "Photo"
  when Post              then "Post"
  else not_found(model.class)
  end
end

.model_class_for(entity_name) ⇒ Object


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/diaspora/federation/mappings.rb', line 50

def self.model_class_for(entity_name)
  case entity_name
  when "Comment"           then Comment
  when "Conversation"      then Conversation
  when "Like"              then Like
  when "Participation"     then Participation
  when "PollParticipation" then PollParticipation
  when "Photo"             then Photo
  when "Poll"              then Poll
  when "Post"              then Post
  when "Person"            then Person # TODO: deprecated
  when "Reshare"           then Post
  when "StatusMessage"     then Post
  else not_found(entity_name)
  end
end

.receiver_for(federation_entity) ⇒ Object

used in Diaspora::Federation::Receive


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/diaspora/federation/mappings.rb', line 9

def self.receiver_for(federation_entity)
  case federation_entity
  when DiasporaFederation::Entities::AccountMigration  then :account_migration
  when DiasporaFederation::Entities::Comment           then :comment
  when DiasporaFederation::Entities::Contact           then :contact
  when DiasporaFederation::Entities::Conversation      then :conversation
  when DiasporaFederation::Entities::Like              then :like
  when DiasporaFederation::Entities::Message           then :message
  when DiasporaFederation::Entities::Participation     then :participation
  when DiasporaFederation::Entities::Photo             then :photo
  when DiasporaFederation::Entities::PollParticipation then :poll_participation
  when DiasporaFederation::Entities::Profile           then :profile
  when DiasporaFederation::Entities::Reshare           then :reshare
  when DiasporaFederation::Entities::StatusMessage     then :status_message
  else not_found(federation_entity.class)
  end
end