Project

General

Profile

Feature #10018

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

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

Status:
Feedback
Priority:
Normal
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.

Also available in: Atom PDF