|
@@ -5,20 +5,17 @@ class User < ActiveRecord::Base |
|
|
alias_attribute :admin?, :is_admin |
|
|
alias_attribute :admin?, :is_admin |
|
|
|
|
|
|
|
|
def characters |
|
|
def characters |
|
|
ensure_api_user |
|
|
|
|
|
chars = @api.characters |
|
|
|
|
|
|
|
|
chars = api.characters |
|
|
chars.nil? ? [] : chars |
|
|
chars.nil? ? [] : chars |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def name |
|
|
def name |
|
|
ensure_api_user |
|
|
|
|
|
sheet = @api.character_sheet(userid) |
|
|
|
|
|
|
|
|
sheet = api.character_sheet(userid) |
|
|
sheet.nil? ? '?' : sheet.name |
|
|
sheet.nil? ? '?' : sheet.name |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def corp_id |
|
|
def corp_id |
|
|
ensure_api_user |
|
|
|
|
|
sheet = @api.character_sheet(userid) |
|
|
|
|
|
|
|
|
sheet = api.character_sheet(userid) |
|
|
sheet.nil? ? 0 : sheet.corporationID.to_i |
|
|
sheet.nil? ? 0 : sheet.corporationID.to_i |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
@@ -31,7 +28,7 @@ class User < ActiveRecord::Base |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
private |
|
|
private |
|
|
def ensure_api_user |
|
|
|
|
|
|
|
|
def api |
|
|
@api ||= Calefaction::EVE::APIUser.new(api_key, api_verify) |
|
|
@api ||= Calefaction::EVE::APIUser.new(api_key, api_verify) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |