Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created December 11, 2011 02:22
Show Gist options
  • Select an option

  • Save pasberth/1457770 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/1457770 to your computer and use it in GitHub Desktop.
module NormallyCase; extend self; end
module NormallyCase
def count_up
@count ||= 0
@count += 1
end
def count_down
@count ||= 0
@count -= 1
end
end
module FlattenScopeCase; extend self; end
FlattenScopeCase.module_eval do
count = 0
define_method :count_up do
count += 1
end
define_method :count_down do
count -= 1
end
end
puts NormallyCase.count_up # 1
puts NormallyCase.count_down # 0
puts FlattenScopeCase.count_up # 1
puts FlattenScopeCase.count_down # 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment