瀏覽代碼

Cleanup.

old-ruby
Ben Kurtovic 9 年之前
父節點
當前提交
4c057ba0aa
共有 2 個檔案被更改,包括 7 行新增11 行删除
  1. +4
    -7
      app/models/user.rb
  2. +3
    -4
      lib/calefaction/eve.rb

+ 4
- 7
app/models/user.rb 查看文件

@@ -5,20 +5,17 @@ class User < ActiveRecord::Base
alias_attribute :admin?, :is_admin

def characters
ensure_api_user
chars = @api.characters
chars = api.characters
chars.nil? ? [] : chars
end

def name
ensure_api_user
sheet = @api.character_sheet(userid)
sheet = api.character_sheet(userid)
sheet.nil? ? '?' : sheet.name
end

def corp_id
ensure_api_user
sheet = @api.character_sheet(userid)
sheet = api.character_sheet(userid)
sheet.nil? ? 0 : sheet.corporationID.to_i
end

@@ -31,7 +28,7 @@ class User < ActiveRecord::Base
end

private
def ensure_api_user
def api
@api ||= Calefaction::EVE::APIUser.new(api_key, api_verify)
end
end

+ 3
- 4
lib/calefaction/eve.rb 查看文件

@@ -39,16 +39,15 @@ module Calefaction::EVE

private
def corporation_sheet(corp_id)
ensure_basic_api
@@api.scope = 'corp'
basic_api.scope = 'corp'
begin
@@api.CorporationSheet(corporationID: corp_id)
basic_api.CorporationSheet(corporationID: corp_id)
rescue EAAL::Exception::EAALError
nil
end
end

def ensure_basic_api
def basic_api
@@api ||= EAAL::API.new(nil, nil)
end
end

Loading…
取消
儲存