From: shyouhei@... Date: 2017-09-25T12:28:14+00:00 Subject: [ruby-core:82991] [Ruby trunk Feature#12533] Refinements: allow modules inclusion, in which the module can call internal methods which it defines. Issue #12533 has been updated by shyouhei (Shyouhei Urabe). We looked at this issue at a developer meeting today. The OP's intension is clear. We can describe how it works, but that seems to be different from how it _should_ work. Matz was there at the discussion so he understands the situation. I'm sure he's going to have some decision. ---------------------------------------- Feature #12533: Refinements: allow modules inclusion, in which the module can call internal methods which it defines. https://bugs.ruby-lang.org/issues/12533#change-66899 * Author: chucke (Tiago Cardoso) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- Right now this isn't possible: ~~~ruby module Extensions def vegetables ; potatoe ; end def potatoe ; "potatoe" ; end end module Refinary refine String do # this doesn't work include Extensions # this would work... # def vegetables ; potatoe ; end # def potatoe ; "potatoe" ; end end end using Refinary puts "tomatoe".vegetables #=> in
': undefined method 'vegetables' for "tomatoe":String ~~~ Wrongly reported as a bug [here](https://bugs.ruby-lang.org/issues/12514). According to Shugo Maeda, this was expected behaviour. I argued that this is the way most monkey-patches work, and if Refinements can't cover the use case of inserting a custom DSL which references itself in the classes it refines, it can't fully replace monkey-patches, which I read was the main reason Refinements have been added to the language. -- https://bugs.ruby-lang.org/ Unsubscribe: