Last active
August 29, 2015 14:12
-
-
Save atton/c5d1f6eb2a2b803ee3cc to your computer and use it in GitHub Desktop.
sinple emluate scoped module by refinements
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
#!/usr/bin/env ruby | |
class ActiveRecord | |
def save | |
puts 'ActiveRecord' | |
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
#!/usr/bin/env ruby | |
module Hoge | |
refine ActiveRecord do | |
def nya | |
save | |
puts 'nya' | |
end | |
def save | |
puts 'hoge save' | |
end | |
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
#!/usr/bin/env ruby | |
require './ar' | |
require './hoge' | |
class A < ActiveRecord | |
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
#!/usr/bin/env ruby | |
require './model' | |
A.new.save # => ActiveRecord | |
A.new.nya # nya is undefined |
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
#!/usr/bin/env ruby | |
require './model' | |
using Hoge | |
A.new.save # hoge | |
A.new.nya # hoge, nya |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment