Sha256: 9becbc3f49671ab7dc230164e4e11792a0a3956e630ccfecd46a97a3b90bd216

Contents?: true

Size: 518 Bytes

Versions: 12

Compression:

Stored size: 518 Bytes

Contents

class Object
  module SingletonMethods
    # returns the singleton class of an object
    def singleton_class
      class << self; self; end
    end

    # defines a method on an object
    def define_object_method(name, &block)
      singleton_class.send :define_method, name, &block
    end
  end

  include SingletonMethods
end

module SingletonMethods::Etest
  def test_singleton_methods
    s = "s"
    s.define_object_method :bla do "blabla" end
    assert_equal("blabla", s.bla)
  end
end if VEX_TEST == "base"

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/base/object/singleton_methods.rb
vex-0.4.4 lib/vex/base/object/singleton_methods.rb
vex-0.4.2 lib/vex/base/object/singleton_methods.rb
vex-0.3.3 lib/vex/base/object/singleton_methods.rb
vex-0.2.9 lib/vex/base/object/singleton_methods.rb
vex-0.2.8 lib/vex/base/object/singleton_methods.rb
vex-0.2.7 lib/vex/base/object/singleton_methods.rb
vex-0.2.6 lib/vex/base/object/singleton_methods.rb
vex-0.2.5 lib/vex/base/object/singleton_methods.rb
vex-0.2.2 lib/vex/base/object/singleton_methods.rb
vex-0.2.1 lib/vex/base/object/singleton_methods.rb
vex-0.2 lib/vex/base/object/singleton_methods.rb