lib/core/facets/module/alias.rb in facets-2.0.5 vs lib/core/facets/module/alias.rb in facets-2.1.0
- old
+ new
@@ -21,30 +21,54 @@
class Module
private
- # Like module_funtion but makes the instance method
- # public rather than private. This can not work
- # as a sectional modifier however.
-
- def module_method *meth
- module_function *meth
- public *meth
- end
-
# As with alias_method, but alias both reader and writer.
#
# attr_accessor :x
# self.x = 1
# alias_accessor :y, :x
# y #=> 1
# self.y = 2
# x #=> 2
- def alias_accessor(name, target)
- alias_method(name, target)
- alias_method("#{name}=", "#{target}=")
+ def alias_accessor(*args)
+ orig = args.last
+ args = args - [orig]
+ args.each do |name|
+ alias_method(name, orig)
+ alias_method("#{name}=", "#{orig}=")
+ end
+ end
+
+ # As with alias_accessor, but just for the reader.
+
+ def alias_reader(*args)
+ orig = args.last
+ args = args - [orig]
+ args.each do |name|
+ alias_method(name, orig)
+ end
+ end
+
+ # As with alias_method but does the writer instead.
+
+ def alias_writer(*args)
+ orig = args.last
+ args = args - [orig]
+ args.each do |name|
+ alias_method("#{name}=", "#{orig}=")
+ end
+ end
+
+ # Like module_funtion but makes the instance method
+ # public rather than private. This can not work
+ # as a sectional modifier however.
+
+ def module_method *meth
+ module_function *meth
+ public *meth
end
# Alias a module function so that the alias is also
# a module function. The typical #alias_method
# does not do this.