diff options
author | Rhenium <rhenium@rhe.jp> | 2014-01-17 06:28:40 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-01-17 06:28:40 +0900 |
commit | 570f0b703878a61fd8bbaeeade08bb2c9a766794 (patch) | |
tree | e79907f92225293b3557ef0f44dbb52746c4f6e9 | |
parent | 366ffacab58dcdec513b2518bc9096a3b30709fc (diff) | |
download | aclog-570f0b703878a61fd8bbaeeade08bb2c9a766794.tar.gz |
refactor Account
-rw-r--r-- | app/models/account.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 7b777ec..b7ea90c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -8,7 +8,7 @@ class Account < ActiveRecord::Base scope :active, -> { where(status: Account::ACTIVE) } def self.create_or_update(hash) - account = where(user_id: hash[:user_id]).first_or_initialize + account = self.where(user_id: hash[:user_id]).first_or_initialize account.oauth_token = hash[:oauth_token] account.oauth_token_secret = hash[:oauth_token_secret] account.status = Account::ACTIVE @@ -43,7 +43,7 @@ class Account < ActiveRecord::Base client = MessagePack::RPC::Client.new(transport, Rails.root.join("tmp", "sockets", "receiver.sock").to_s) client.call(:register, Marshal.dump(self)) rescue Errno::ECONNREFUSED, Errno::ENOENT - Rails.logger.error($!) + Rails.logger.error "Account#update_connection: couldn't connect to the receiver" end def client @@ -53,10 +53,6 @@ class Account < ActiveRecord::Base oauth_token_secret: oauth_token_secret) end - def import_favorites(id) - raise Exception, "not implemented" - end - def following?(target_user_id) api_friendship?(user_id, target_user_id) end @@ -67,11 +63,11 @@ class Account < ActiveRecord::Base private def api_friendship?(source_user_id, target_user_id) - return nil unless source_user_id && source_user_id.is_a?(Integer) - return nil unless target_user_id && target_user_id.is_a?(Integer) + return nil unless source_user_id.is_a?(Integer) + return nil unless target_user_id.is_a?(Integer) Rails.cache.fetch("friendship/#{source_user_id}-#{target_user_id}", expires_in: 3.days) do - client.friendship?(source_user_id, target_user_id) rescue nil + self.client.friendship?(source_user_id, target_user_id) rescue nil end end end |