Class: Turl::Tweet

Inherits:
ApplicationRecord show all
Defined in:
lib/turl/tweet.rb

Class Method Summary collapse

Class Method Details

.from_response!(tweet_resp) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/turl/tweet.rb', line 6

def self.from_response!(tweet_resp)
  user = TwitterUser.from_response!(tweet_resp.user)
  find_or_initialize_by(twitter_id: tweet_resp.id).tap do |t|
    t.update!(
      content: tweet_resp.text,
      twitter_user: user,
      tweeted_at: tweet_resp.created_at,
    )
  end
end