Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 814bb1156506
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7901f47cb8db
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 14, 2018

  1. Add MRI test for Module new public methods

    New public methods on Module class:
    
      - attr
      - attr_accessor
      - attr_reader
      - attr_writer
    nomadium committed Feb 14, 2018
    Copy the full SHA
    1bb4456 View commit details
  2. Module#attr, attr_accessor, attr_reader, attr_writer are now public

    For more information, please see feature #14132.
    nomadium committed Feb 14, 2018
    Copy the full SHA
    62c5de5 View commit details

Commits on Feb 15, 2018

  1. Merge pull request #5043 from nomadium/module-attr-methods-are-now-pu…

    …blic
    
    Module#attr, attr_accessor, attr_reader, attr_writer are now public
    enebo authored Feb 15, 2018
    Copy the full SHA
    7901f47 View commit details
Showing with 16 additions and 4 deletions.
  1. +4 −4 core/src/main/java/org/jruby/RubyModule.java
  2. +12 −0 test/mri/ruby/test_module.rb
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -2362,7 +2362,7 @@ public void addWriteAttribute(ThreadContext context, String name) {
/** rb_mod_attr
*
*/
@JRubyMethod(name = "attr", rest = true, visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "attr", rest = true, reads = VISIBILITY)
public IRubyObject attr(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;

@@ -2388,7 +2388,7 @@ public IRubyObject attr_reader(IRubyObject[] args) {
/** rb_mod_attr_reader
*
*/
@JRubyMethod(name = "attr_reader", rest = true, visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "attr_reader", rest = true, reads = VISIBILITY)
public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args) {
// Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed
Visibility visibility = context.getCurrentVisibility();
@@ -2403,7 +2403,7 @@ public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args) {
/** rb_mod_attr_writer
*
*/
@JRubyMethod(name = "attr_writer", rest = true, visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "attr_writer", rest = true, reads = VISIBILITY)
public IRubyObject attr_writer(ThreadContext context, IRubyObject[] args) {
// Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed
Visibility visibility = context.getCurrentVisibility();
@@ -2425,7 +2425,7 @@ public IRubyObject attr_accessor(IRubyObject[] args) {
* Note: this method should not be called from Java in most cases, since
* it depends on Ruby frame state for visibility. Use add[Read/Write]Attribute instead.
*/
@JRubyMethod(name = "attr_accessor", rest = true, visibility = PRIVATE, reads = VISIBILITY)
@JRubyMethod(name = "attr_accessor", rest = true, reads = VISIBILITY)
public IRubyObject attr_accessor(ThreadContext context, IRubyObject[] args) {
// Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed
Visibility visibility = context.getCurrentVisibility();
12 changes: 12 additions & 0 deletions test/mri/ruby/test_module.rb
Original file line number Diff line number Diff line change
@@ -2030,6 +2030,18 @@ def test_remove_const
assert_raise(NameError){ m.instance_eval { remove_const(:__FOO__) } }
end

def test_public_methods
public_methods = %i[
include
prepend
attr
attr_accessor
attr_reader
attr_writer
]
assert_equal public_methods.sort, (Module.public_methods & public_methods).sort
end

def test_private_top_methods
assert_top_method_is_private(:include)
assert_top_method_is_private(:public)