Skip to content

Instantly share code, notes, and snippets.

@csaunders
Created May 17, 2013 15:00
Show Gist options
  • Save csaunders/5599621 to your computer and use it in GitHub Desktop.
Save csaunders/5599621 to your computer and use it in GitHub Desktop.
What are your thoughts on using this style for ensuring modules are able to be included at the top of the file? Is there something in the Ruby runtime I'm missing that would cause this to break?
module AddsFunctionality
extend ActiveSupport::Concern
alias_method :foo, :baz
end
def baz
puts "Hello Baz"
end
end
# This is what I'd like to do
class FancyClass
def foo; end
include AddsFunctionality
def foo
puts "Hello Foo"
end
end
# Instead of
class Fancy Class
def foo
puts "Hello Foo"
end
include AddsFunctionality
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment