[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-core
Subject: [ruby-core:76206] [Ruby trunk Feature#12533] Refinements: allow modules inclusion,
From: futu.fata () gmail ! com
Date: 2016-06-29 13:34:35
Message-ID: redmine.journal-59422.20160629133435.5ed0c89ad4688b4f () ruby-lang ! org
[Download RAW message or body]
Issue #12533 has been updated by Artem Khramov.
Hi Tiago, the syntax is
\~\~\~ruby
your(code).goes here
\~\~\~
Sorry for offtop.
----------------------------------------
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-59422
* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
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 <main>': 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic