Skip to content

Commit

Permalink
Delegating instead of creating a method for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
lunks committed Apr 3, 2012
1 parent dba9665 commit c465095
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/models/facility_fleet.rb
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down

2 comments on commit c465095

@rmorali
Copy link
Collaborator

@rmorali rmorali commented on c465095 Apr 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@lunks
Copy link
Owner Author

@lunks lunks commented on c465095 Apr 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.