It seems that module_function with no parameters doesn't trigger creation o=
f singleton methods for methods defined by 'define_method' or accessors. Ru=
by 1.8 only changes visibility of the methods to private, while Ruby 1.9 do=
esn't even do that.

On the other hand, contrary to parameter-less version, module_function with=
 parameters creates singleton methods for all methods, whether created via =
define_method or accessors or def keyword.

Is 1.9's behavior an expected one?


------------------------
Source:
------------------------
puts RUBY_VERSION

puts 'M:'
module M
  module_function

  def meth
  end

  define_method :def_meth do
  end

  attr_accessor :accessor

  p instance_methods(false).sort
  p private_instance_methods(false).sort
  p singleton_methods(false).sort
end

puts 'N:'
module N
  def meth
  end

  define_method :def_meth do
  end

  attr_accessor :accessor

  module_function :meth, :def_meth, :accessor, :accessor=3D

  p instance_methods(false).sort
  p private_instance_methods(false).sort
  p singleton_methods(false).sort
end

------------------------
Output (1.8.6):
------------------------
1.8.6
M:
[]
["accessor", "accessor=3D", "def_meth", "meth"]
["meth"]
N:
[]
["accessor", "accessor=3D", "def_meth", "meth"]
["accessor", "accessor=3D", "def_meth", "meth"]

------------------------
Output (1.9.0):
------------------------
1.9.0
M:
[:accessor, :accessor=3D, :def_meth, :meth]
[]
[:meth]
N:
[]
[:accessor, :accessor=3D, :def_meth, :meth]
[:accessor, :accessor=3D, :def_meth, :meth]

Tomas