Class: Module

Inherits:
Object show all
Defined in:
lib/waw/ext/core/module.rb

Instance Method Summary collapse

Instance Method Details

#deprecated(msg = "The method ${method_name} is deprecated") ⇒ Object



3
4
5
# File 'lib/waw/ext/core/module.rb', line 3

def deprecated(msg = "The method ${method_name} is deprecated")
  @deprecated = msg
end

#method_added(name) ⇒ Object

If a signature has been installed, let the next added method become an action



9
10
11
12
13
14
15
16
17
18
# File 'lib/waw/ext/core/module.rb', line 9

def method_added(name)
  if @deprecated
    deprecated, @deprecated = @deprecated.gsub(/#{Regexp.escape('${method_name}')}/, "#{self.name}.#{name}"), nil
    method = instance_method(name)
    define_method name do |*args|
      $waw_deprecated_io << deprecated << " (#{caller[0]})\n" if $waw_deprecated_io
      method.bind(self).call(*args)
    end 
  end
end