Skip to content

Instantly share code, notes, and snippets.

@tdg5
Created January 15, 2015 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdg5/4b5f273b0f5da521cb88 to your computer and use it in GitHub Desktop.
Save tdg5/4b5f273b0f5da521cb88 to your computer and use it in GitHub Desktop.
Lexical Scope Is Weird
module LexicalScope
SCOPED_CONSTANT = [:lexical_scope].freeze
def scoped_value
value = defined?(super) ? super.dup : []
value.concat(SCOPED_CONSTANT)
end
end
module IsWeird
SCOPED_CONSTANT = [:is_weird].freeze
def scoped_value
value = defined?(super) ? super.dup : []
value.concat(SCOPED_CONSTANT)
end
end
class LexicalScopeIsWeird
SCOPED_CONTANT = [:lexical_scope_is_awesome!]
include LexicalScope
include IsWeird
end
LexicalScopeIsWeird.new.scoped_value
# => [:lexical_scope, :is_weird]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment