Skip to content

Instantly share code, notes, and snippets.

@xpepper
Created May 16, 2012 12:23
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 xpepper/2709939 to your computer and use it in GitHub Desktop.
Save xpepper/2709939 to your computer and use it in GitHub Desktop.
Adding autoload feature to a Ruby class
class Document
def self.reload
instance_methods(false).each { |m| remove_method(m) }
class << self
Document.methods(false).reject {|m| m == "reload" }.each do |m|
remove_method(m)
end
end
load(__FILE__)
end
def initialize(name)
@name = name
end
def name
@name.upcase
end
# def self.ciao
# "ciao"
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment