Commit Graph

8 Commits

Author SHA1 Message Date
Harry Maclean
4df7fd248e Ruby: Ensure explicit modifiers take priority
In Ruby, "explicit" visibility modifiers override "implicit" ones. For
example, in the following:

```rb
class C

  private

  def m1
  end

  public m2
  end

  def m3
  end
  public :m3
end
```

`m1` is private whereas `m2` and `m3` are public.
2022-09-27 10:28:23 +13:00
Harry Maclean
5e9196e51c Ruby: Add test for protected methods 2022-09-27 10:21:04 +13:00
Harry Maclean
494fb4c966 Ruby: Make room for new test cases 2022-09-27 10:18:43 +13:00
Tom Hvitved
37a2b7d0b3 Ruby: Add more call graph tests for private methods 2022-09-21 14:00:17 +02:00
Harry Maclean
6223b166c2 Update test fixtures
At the same time, rename some classes in `private.rb` so they don't
interact with identically-named modules in `calls.rb`.
2021-12-13 16:24:25 +13:00
Harry Maclean
8df5aaa797 Ruby: Model private class methods
`Module#private_class_method` takes a symbol representing the name of a
method in the current module scope and makes that module private. This
is similar to `private`, but applies only to class (singleton) methods.
Unlike `private`, it must be called with an argument, and does not
change the ambient visibility for any subsequent method definitions.

    class Foo
      def public
      end

      def private1
      end
      private_class_method :private1

      # This alternate form works because method definition
      # returns its name as a symbol:

      private_class_method def private2
      end
    end
2021-12-09 18:15:25 +13:00
Harry Maclean
e811ba1150 Ruby: handle private module methods
`private` can be used in both classes and modules.
2021-12-09 18:13:29 +13:00
Arthur Baars
976daddd36 Move files to ruby subfolder 2021-10-15 11:47:28 +02:00