Class: TopicsBulkAction
- Inherits:
-
Object
- Object
- TopicsBulkAction
- Defined in:
- lib/topics_bulk_action.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, topic_ids, operation, options = {}) ⇒ TopicsBulkAction
constructor
A new instance of TopicsBulkAction.
- #perform! ⇒ Object
Constructor Details
#initialize(user, topic_ids, operation, options = {}) ⇒ TopicsBulkAction
Returns a new instance of TopicsBulkAction.
4 5 6 7 8 9 10 |
# File 'lib/topics_bulk_action.rb', line 4 def initialize(user, topic_ids, operation, = {}) @user = user @topic_ids = topic_ids @operation = operation @changed_ids = [] @options = end |
Class Method Details
.operations ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/topics_bulk_action.rb', line 12 def self.operations @operations ||= %w[ change_category close silent_close archive change_notification_level destroy_post_timing dismiss_posts delete unlist archive_messages move_messages_to_inbox change_tags append_tags remove_tags relist dismiss_topics reset_bump_dates ] end |
.register_operation(name, &block) ⇒ Object
34 35 36 37 |
# File 'lib/topics_bulk_action.rb', line 34 def self.register_operation(name, &block) operations << name define_method(name, &block) end |
Instance Method Details
#perform! ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/topics_bulk_action.rb', line 39 def perform! if TopicsBulkAction.operations.exclude?(@operation[:type]) raise Discourse::InvalidParameters.new(:operation) end # careful these are private methods, we need send send(@operation[:type]) @changed_ids.sort end |