Welcome to mirror list, hosted at ThFree Co, Russian Federation.

participation.rb « models « app - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 94d82fb95c7929449f22124cb176cc976a57dbb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Participation < ActiveRecord::Base
  include Diaspora::Federated::Base
  include Diaspora::Fields::Guid
  include Diaspora::Fields::Author
  include Diaspora::Fields::Target

  class Generator < Diaspora::Federated::Generator
    def self.federated_class
      Participation
    end

    def relayable_options
      {:target => @target}
    end
  end

  def unparticipate!
    if count == 1
      destroy
    else
      update!(count: count.pred)
    end
  end

  # @return [Array<Person>]
  def subscribers
    [target.author]
  end

  # NOTE API V1 to be extracted
  acts_as_api
  api_accessible :backbone do |t|
    t.add :id
    t.add :guid
    t.add :author
    t.add :created_at
  end
end