Sha256: 4d87a1e74ab6623baf3a27952652e20874e7f9ff4d06c2238e126157d2256e64

Contents?: true

Size: 778 Bytes

Versions: 10

Compression:

Stored size: 778 Bytes

Contents

module Kernel

  # Kernel extension prefixed by instance_ which provide
  # internal (eg private) access to the object.
  # Kernel extension using instance_ prefix which is beneficial
  # to separation of metaprogramming from general programming.
  # object_ methods, in contrast to the instance_ methods,
  # do not access internal state.

  # Easy access to an object qua class, otherwise known
  # as the object's metaclass or singleton class. This
  # implemnetation alwasy returns the class, even if a
  # block is provided to eval against it...
  #
  #     It is what it is.
  #     But I think I like this one best.
  #
  # CREDIT: Trans

  def instance_class(&block)
    (class << self; self; end).module_eval(&block) if block
    (class << self; self; end)
  end

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/kernel/instance_class.rb
facets-3.1.0 lib/core/facets/kernel/instance_class.rb
facets-3.0.0 lib/core/facets/kernel/instance_class.rb
facets-2.9.3 lib/core/facets/kernel/instance_class.rb
facets-2.9.2 src/core/facets/kernel/instance_class.rb
facets-2.9.2 lib/core/facets/kernel/instance_class.rb
facets-2.9.1 lib/core/facets/kernel/instance_class.rb
facets-2.9.0 lib/core/facets/kernel/instance_class.rb
facets-2.9.0.pre.2 lib/core/facets/kernel/instance_class.rb
facets-2.9.0.pre.1 lib/core/facets/kernel/instance_class.rb