module Rdecorator
Constants
- VERSION
Public Class Methods
new(this, *args)
click to toggle source
# File lib/rdecorator.rb, line 5 def initialize(this, *args) @this = this @args = args end
Public Instance Methods
decorator_methods()
click to toggle source
# File lib/rdecorator.rb, line 44 def decorator_methods @decorator_methods ||= [] end
method_added(method_name)
click to toggle source
# File lib/rdecorator.rb, line 10 def method_added(method_name) unless decorator_methods.empty? decorator_method = decorator_methods.pop new_name = "#{method_name}_without_decorator" alias_method new_name, method_name define_method method_name do |*args| fn = method(new_name) callback = Proc.new {|p = args| fn.call(*p)} if decorator_method.kind_of? Class decorator_method.new(fn, *args).call &callback else method(decorator_method).call fn, *args, &callback end end end end
wrap(decorator)
click to toggle source
# File lib/rdecorator.rb, line 38 def wrap(decorator) decorator_methods << decorator end
Also aliased as: decorator