Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/sashimi/core_ext/class.rb
Instance Method Summary collapse
-
#class_method_proxy(*method_names) ⇒ Object
Dinamically creates a proxy for given class methods.
Instance Method Details
#class_method_proxy(*method_names) ⇒ Object
Dinamically creates a proxy for given class methods.
Example:
class Repository
def self.path
@@path
end
class_method_proxy :path
end
It produces:
# Proxy method for <tt>Repository#path</tt>
def path
self.class.path
end
private :path
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sashimi/core_ext/class.rb', line 20 def class_method_proxy(*method_names) method_names.each do |m| self.class_eval %{ # Proxy method for <tt>#{self.class.name}##{m}</tt> def #{m}(*args, &block) self.class.#{m}(*args, &block) end private :#{m} }, __FILE__, __LINE__ end end |