class PublicForwarder
Public Class Methods
new(object)
click to toggle source
# File lib/api_hammer/public_instance_exec.rb, line 2 def initialize(object) @object=object end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
forwards public methods to the object. attempting to invoke private or protected methods raises, as it would if the object was a normal receiver.
# File lib/api_hammer/public_instance_exec.rb, line 8 def method_missing(method, *args, &block) if @object.protected_methods.any?{|pm| pm.to_s == method.to_s } ::Kernel.raise ::NoMethodError, "protected method `#{method}' called for #{@object.inspect}" elsif @object.private_methods.any?{|pm| pm.to_s == method.to_s } ::Kernel.raise ::NoMethodError, "private method `#{method}' called for #{@object.inspect}" else @object.__send__(method, *args, &block) end end