Class: Corporation
- Inherits:
-
Object
- Object
- Corporation
- Includes:
- MongoidSetup
- Defined in:
- lib/generators/rails_eve/install/templates/corporation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create_from_api(corporation_id) ⇒ Object
20 21 22 23 |
# File 'lib/generators/rails_eve/install/templates/corporation.rb', line 20 def self.create_from_api(corporation_id) api_corporation = ESI::CorporationApi.new.get_corporations_corporation_id(corporation_id) where(id: corporation_id, name: api_corporation.name, ticker: api_corporation.ticker, alliance_id: api_corporation.alliance_id).first_or_create end |
.update_counter_caches ⇒ Object
13 14 15 16 17 18 |
# File 'lib/generators/rails_eve/install/templates/corporation.rb', line 13 def self.update_counter_caches all.each do |user| user.characters_count = user.characters.count user.save end end |
Instance Method Details
#create_alliance ⇒ Object
25 26 27 28 29 |
# File 'lib/generators/rails_eve/install/templates/corporation.rb', line 25 def create_alliance return false unless alliance_id Alliance.create_from_api(alliance_id) end |