Module: Dekoden::SingletonPrependMethods

Defined in:
lib/dekoden.rb

Instance Method Summary collapse

Instance Method Details

#method_added(method_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dekoden.rb', line 5

def method_added(method_name)
  unless unbound_decorators.empty?
    decorators_for_method = unbound_decorators.dup
    unbound_decorators.clear
    decorated_methods.module_eval do
      define_method(method_name) do |*args, &blk|
        Helpers.wrap(decorators_for_method, *args, blk) do |*args, blk|
          super(*args, &blk)
        end
      end
    end
  end
  super
end

#singleton_method_added(method_name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dekoden.rb', line 20

def singleton_method_added(method_name)
  unless unbound_decorators.empty?
    decorators_for_method = unbound_decorators.dup
    unbound_decorators.clear
    decorated_singleton_methods.module_eval do
      define_method(method_name) do |*args, &blk|
        Helpers.wrap(decorators_for_method, *args, blk) do |*args, blk|
          super(*args, &blk)
        end
      end
    end
  end
  super
end