lib/junk_drawer/callable.rb in junk_drawer-1.1.0 vs lib/junk_drawer/callable.rb in junk_drawer-1.1.1
- old
+ new
@@ -25,13 +25,21 @@
def to_proc
new.to_proc
end
def method_added(method_name)
- return if method_name == :call || !public_method_defined?(method_name)
+ return if valid_callable_method?(method_name)
raise CallableError, "invalid method name #{method_name}, " \
'only public method allowed is "call"'
+ end
+
+ private
+
+ def valid_callable_method?(method_name)
+ method_name == :call ||
+ !public_method_defined?(method_name) ||
+ method_name.to_s.start_with?('__')
end
end
def self.included(base)
base.public_send(:extend, ClassMethods)