-
-
Save joho/26034 to your computer and use it in GitHub Desktop.
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
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def scoped_variable(*objects) | |
yield(objects) | |
end | |
alias scoped_variable scoped_variables | |
end | |
@reports = [] | |
scoped_variable 'Sales' do |group| | |
@reports << Report.new(:name => 'First', :group => group) | |
@reports << Report.new(:name => 'Second', :group => group) | |
@reports << Report.new(:name => 'Third', :group => group) | |
end | |
scoped_variables 'Traffic', 'Ninjas' do |group, assassin| | |
@reports << Report.new(:name => 'Fourth', :group => group, :assassin) | |
@reports << Report.new(:name => 'Fifth', :group => group, :assassin) | |
@reports << Report.new(:name => 'Sixth', :group => group, :assassin) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment