Project

General

Profile

Actions

Feature #10018

closed

Consider adding Sub-Includes as in include Foo::bar

Added by shevegen (Robert A. Heiler) almost 10 years ago. Updated almost 10 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:63601]

Description

On IRC someone asked a nice question:

<arup_r> If I write class Foo; include Enumerable; end This code include all methods from Enumerable. But suppose I want to include #all?, #any? .. What's the way to include only required methods ?

This prompted me to write this.

What if ruby would allow us to include just singular methods?

Something like:

include Enumerable::any?

And so forth, so that we could cherry-pick what we want.

This is already possible in some projects, like facets.

But I think they solve it by splitting up the whole
stuff into individual files, and then including
this.

I think it would be nicer if include itself would
support a scope-mechanic.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0