Skip to content

Instantly share code, notes, and snippets.

@ryan-allen
Created November 18, 2008 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryan-allen/26031 to your computer and use it in GitHub Desktop.
Save ryan-allen/26031 to your computer and use it in GitHub Desktop.
# DRY temporary variables that require single use only, without assignment... seems
# useful for configuration files perhaps? urgh.
class Object
def with(object)
yield(object)
end
end
@reports = []
with '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
with 'Traffic' do |group|
@reports << Report.new(:name => 'Fourth', :group => group)
@reports << Report.new(:name => 'Fifth', :group => group)
@reports << Report.new(:name => 'Sixth', :group => group)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment