lib/junk_drawer/callable.rb in junk_drawer-1.0.0 vs lib/junk_drawer/callable.rb in junk_drawer-1.1.0

- old
+ new

@@ -8,15 +8,23 @@ module Callable def call raise NotImplementedError end + def to_proc + proc { |args| self.(*args) } + end + # `ClassMethods` defines a class level method `call` that delegates to # an instance. It also causes an error to be raised if a public instance # method is defined with a name other than `call` module ClassMethods def call(*args) new.(*args) + end + + def to_proc + new.to_proc end def method_added(method_name) return if method_name == :call || !public_method_defined?(method_name)