Class: TopicStatusUpdater

Inherits:
Struct
  • Object
show all
Defined in:
app/services/topic_status_updater.rb

Defined Under Namespace

Classes: Status

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#topicObject

Returns the value of attribute topic

Returns:

  • (Object)

    the current value of topic



3
4
5
# File 'app/services/topic_status_updater.rb', line 3

def topic
  @topic
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



3
4
5
# File 'app/services/topic_status_updater.rb', line 3

def user
  @user
end

Instance Method Details

#update!(status, enabled, opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/topic_status_updater.rb', line 5

def update!(status, enabled, opts = {})
  status = Status.new(status, enabled)

  @topic_timer = topic.public_topic_timer

  updated = nil
  Topic.transaction do
    updated = change(status, opts)
    if updated
      highest_post_number = topic.highest_post_number
      create_moderator_post_for(status, opts)
      update_read_state_for(status, highest_post_number)
    end
  end

  updated
end