diff app/models/tweet.rb @ 47:e5082c4c234d

Also allow config-file-based configuration.
author nanaya <me@myconan.net>
date Thu, 23 Apr 2015 16:05:08 +0900
parents 205c0b5d9f44
children 8983c426e256
line wrap: on
line diff
--- a/app/models/tweet.rb	Thu Apr 23 15:32:56 2015 +0900
+++ b/app/models/tweet.rb	Thu Apr 23 16:05:08 2015 +0900
@@ -1,11 +1,4 @@
 class Tweet
-  CONFIG = {
-    :consumer_key => ENV["RT_CONSUMER_KEY"],
-    :consumer_secret => ENV["RT_CONSUMER_SECRET"],
-    :access_token => ENV["RT_ACCESS_TOKEN"],
-    :access_token_secret => ENV["RT_ACCESS_TOKEN_SECRET"]
-  }
-
   def timeline
     @timeline ||=
       Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => 5.minutes) do
@@ -15,7 +8,7 @@
 
   def initialize(twitter_id)
     @client = Twitter::REST::Client.new do |config|
-      CONFIG.each do |cfg_key, cfg_value|
+      CFG[:twitter].each do |cfg_key, cfg_value|
         config.public_send("#{cfg_key}=", cfg_value)
       end
     end