Class: TweetInspector

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/tweet_inspector.rb

Instance Method Summary collapse

Instance Method Details

#perform(id) ⇒ Object

It analyzes a Tweet and creates an Infraction if necessary



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/workers/tweet_inspector.rb', line 5

def perform(id)
  if (tweet = Tweet.find_by(id: id))
    return if tweet.infraction

    infraction = Infraction.build_from(tweet)

    if infraction.save
      puts "Great success!"
    else
      Rails.logger.info "Could not save Infraction: #{infraction.errors.messages}"
    end
  end
end