Created
August 5, 2017 17:46
-
-
Save nalabjp/72c53b397008d08d90eee6180d059a19 to your computer and use it in GitHub Desktop.
This file contains 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 DSL | |
def capture | |
'DSL#capture' | |
end | |
end | |
module Helper | |
def call_capture | |
capture | |
end | |
end | |
class Klass | |
def initialize(context) | |
@contenxt = context | |
end | |
def with_context(&block) | |
@contenxt.instance_eval(&block) | |
end | |
end | |
class SubKlass < Klass | |
def call_capture | |
with_context { capture } | |
end | |
end | |
class Pseudo | |
include DSL | |
include Helper | |
def run | |
puts "call `capture`: #{capture}" | |
puts "call `call_capture`: #{call_capture}" | |
k = SubKlass.new(binding.receiver) | |
puts "call `SubKlass#respond_to?(:capture)`: #{k.respond_to?(:capture)}" | |
puts "call `SubKlass#call_capture`: #{k.call_capture}" | |
end | |
end | |
Pseudo.new.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment