module Tangle::Currify

Currification of instance methods, for adding callbacks to other objects

Public Class Methods

included(base) click to toggle source
# File lib/tangle/currify.rb, line 13
def self.included(base)
  base.extend(ClassMethods)
end

Private Instance Methods

define_currified_methods(obj, tag) click to toggle source
# File lib/tangle/currify.rb, line 48
def define_currified_methods(obj, tag)
  self.class.currified_methods(tag)&.each do |name|
    obj.instance_exec(name, method(name).curry) do |method_name, method|
      define_singleton_method(method_name) do |*args|
        method.call(self, *args)
      end
    end
  end
end