Class: Dry::Monads::Do::All::MethodTracker

Inherits:
Module
  • Object
show all
Defined in:
lib/dry/monads/do/all.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrappers) ⇒ MethodTracker

Returns a new instance of MethodTracker.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/dry/monads/do/all.rb', line 62

def initialize(wrappers)
  super()

  @wrappers = wrappers
  tracker = self

  module_eval do
    private

    define_method(:method_added) do |method|
      super(method)
      tracker.wrap_method(self, method)
    end

    define_method(:inherited) do |base|
      super(base)

      base.prepend(wrappers[base])
    end

    def included(base)
      super
      All.included(base)
    end
  end
end

Instance Attribute Details

#wrappersObject (readonly)



60
61
62
# File 'lib/dry/monads/do/all.rb', line 60

def wrappers
  @wrappers
end

Instance Method Details

#extend_object(target) ⇒ Object



89
90
91
92
# File 'lib/dry/monads/do/all.rb', line 89

def extend_object(target)
  super
  target.prepend(wrappers[target])
end

#wrap_method(target, method) ⇒ Object



94
95
96
97
# File 'lib/dry/monads/do/all.rb', line 94

def wrap_method(target, method)
  visibility = Do.method_visibility(target, method)
  Do.wrap_method(wrappers[target], method, visibility)
end