Created
November 7, 2010 14:04
-
-
Save Antiarchitect/666139 to your computer and use it in GitHub Desktop.
Alternative way of method factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Financing::FINANCINGS.each do |method| | |
define_method method do | |
if current_period && current_period != :nil | |
instance_variable_defined?("@#{method}") ? nil : instance_variable_set("@#{method}", Hash.new) | |
instance_variable_get("@#{method}")[current_period.id] ||= current_period.method("#{method}").call | |
else | |
0.0 | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Financing::FINANCINGS.each do |method| | |
define_method method do | |
if current_period && current_period != :nil | |
instance_variable_defined?("@#{method}") ? nil : instance_variable_set("@#{method}", Hash.new) | |
instance_variable_get("@#{method}")[current_period.id] ||= current_period.send(method) | |
else | |
0.0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment