2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
module ToggleSubscriptionAction
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def toggle_subscription
|
|
|
|
return unless current_user
|
|
|
|
|
2016-10-31 15:21:13 -04:00
|
|
|
subscribable_resource.toggle_subscription(current_user, subscribable_project)
|
2016-03-15 12:24:55 -04:00
|
|
|
|
2016-03-15 21:16:25 -04:00
|
|
|
head :ok
|
2016-03-15 12:24:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-10-31 15:21:13 -04:00
|
|
|
def subscribable_project
|
2017-11-17 07:27:16 -05:00
|
|
|
@project ||= raise(NotImplementedError)
|
2016-10-31 15:21:13 -04:00
|
|
|
end
|
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
def subscribable_resource
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|