Issue #9992 has been updated by Daniel Ferreira.


There is a proposal for a namespace method: [Object#namespace](https://bugs.ruby-lang.org/issues/12317).
The namespace method would make it viable the implementation of `Module#internal` and simplify a lot the code I have put in place as a proof of concept in my gem [internal](https://github.com/dsferreira/internal)
If we do: 

~~~ ruby
namespace_root = ::Foo::Bar.namespace.last
~~~

Then **Module#internal** would behave like:

1. Public method if called inside `namespace_root`
2. Private method if called outside `namespace_root`

----------------------------------------
Feature #9992: Access Modifiers (Internal Interfaces)
https://bugs.ruby-lang.org/issues/9992#change-58696

* Author: Daniel Ferreira
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Hi,
 
Im would like to discuss with you the concept of Internal Interfaces.
 
Currently ruby offers three access modifiers choices to set methods visibility:

- public
- protected
- private

Public methods define what we may call the Public Interface.
Private methods are private to the class and its subclasses.
Protected methods are public for the subclasses.
 
I would like to work with a new access modifier that would allow the creation of Internal methods.
 
Internal methods would be object methods that could only be called within the namespace.
 
Ex:

~~~ruby
module Foo; end

class Foo::Bar
  def baz 
     puts baz
  end
  internal :baz
end

class Foo::Qux
  def baz
     ::Foo::Bar.new.baz
  end
end
~~~

Is this something that we can think about in a future implementation of ruby?
An extra feature that would not break backward compatibility.
 
Cheers,
Daniel



-- 
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>