Sha256: 70ef0a3ded6e910d4fc49588333923a7ca55b31b5de760b80d8b28ec39adb4bd

Contents?: true

Size: 621 Bytes

Versions: 6

Compression:

Stored size: 621 Bytes

Contents

module Kernel

  # Send only to public methods.
  #
  #   class X
  #     private
  #     def foo; end
  #   end
  #
  #   X.new.object_send(:foo)
  #   => NoMethodError: private method `foo' called for #<X:0xb7ac6ba8>
  #
  # TODO: object_send needs to change for 1.9.
  #
  # CREDIT: Trans
  #--
  # Which implementation is faster?
  #++

  def object_send(name,*args,&blk)
    #instance_eval "self.#{name}(*args)"
    if respond_to?(name)
      __send__(name,*args,&blk)
    else #if respond_to?(:method_missing)
      __send__(:method_missing,name,*args,&blk)
    #else
    #  raise NoMethodError
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/kernel/object_send.rb
facets-2.8.3 lib/core/facets/kernel/object_send.rb
facets-2.8.2 lib/core/facets/kernel/object_send.rb
facets-2.8.1 lib/core/facets/kernel/object_send.rb
facets-2.8.0 lib/core/facets/kernel/object_send.rb
facets-2.7.0 lib/core/facets/kernel/object_send.rb