Permalink
Browse files

Delegating instead of creating a method for it.

  • Loading branch information...
1 parent dba9665 commit c4650950cc80babb5b46fba0093dfdc22042ea9a @lunks committed Apr 3, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 app/models/facility_fleet.rb
@@ -3,6 +3,8 @@ class FacilityFleet < GenericFleet
validates_presence_of :facility, :squad
belongs_to :facility, :foreign_key => :generic_unit_id
belongs_to :producing_unit, :class_name => "Unit"
+
+ delegate :capacity, :to => :facility
class << self
def is_free
FacilityFleet.skip_callback(:create, :before, :subtract_credits_from_squad)
@@ -25,9 +27,6 @@ def units_per_turn
((capacity + balance) / producing_unit.price.to_f).round(2)
end
- def capacity
- facility.capacity
- end
def building_done
(balance / producing_unit.price.to_f).round(2)
@@ -36,7 +35,7 @@ def building_done
def producing_unit_display
if units_per_turn < 1
producing_unit_display = producing_unit.name + " #{building_done}%"
- else
+ else
producing_unit_display = producing_unit.name
end
producing_unit_display

2 comments on commit c465095

@rmorali
Collaborator
rmorali commented on c465095 Apr 4, 2012

O que faz o delegate? Onde foi parar o metodo capacity?

Please sign in to comment.