Last active
December 12, 2015 12:29
-
-
Save kotp/4772181 to your computer and use it in GitHub Desktop.
Exploring modules, constants and methods
This file contains hidden or 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
puts "Loading global_var.rb" | |
GlobalConstant = 'GlobalConstant' | |
$GlobalConstant_WithDollarSign = 'Global Constant with Dollar Sign' | |
module SharedVar | |
NAMESPACED_CONSTANT = 'Named spaced constant' | |
def your_method | |
"Whatever your method would be." | |
end | |
end | |
This file contains hidden or 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
require './global_var' | |
include SharedVar | |
puts GlobalConstant | |
puts $GlobalConstant_WithDollarSign | |
puts SharedVar::NAMESPACED_CONSTANT | |
puts SharedVar::your_method | |
require_relative 'global_var'
unless you're building a gem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me see if this is what we are talking about.
You really want to instantiate a instance method on a module that is not instantiable?
Can you show some code? You can use code markup here. Or you can do a hangout with me (accept the chat requests you should have received) or request one from me.