Created
May 17, 2013 15:00
-
-
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?
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
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