Class: BookmarksBulkAction

Inherits:
Object
  • Object
show all
Defined in:
lib/bookmarks_bulk_action.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, bookmark_ids, operation, options = {}) ⇒ BookmarksBulkAction

Returns a new instance of BookmarksBulkAction.



4
5
6
7
8
9
10
# File 'lib/bookmarks_bulk_action.rb', line 4

def initialize(user, bookmark_ids, operation, options = {})
  @user = user
  @bookmark_ids = bookmark_ids
  @operation = operation
  @changed_ids = []
  @options = options
end

Class Method Details

.operationsObject



12
13
14
# File 'lib/bookmarks_bulk_action.rb', line 12

def self.operations
  @operations ||= %w[clear_reminder delete]
end

Instance Method Details

#perform!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bookmarks_bulk_action.rb', line 16

def perform!
  if BookmarksBulkAction.operations.exclude?(@operation[:type])
    raise Discourse::InvalidParameters.new(:operation)
  end

  case @operation[:type]
  when "clear_reminder"
    clear_reminder
  when "delete"
    delete
  end

  @changed_ids.sort
end