Sha256: aa2f7390179fe01d714b1fb37209ccf0f377f6352bcac958fc023229f3d91f67

Contents?: true

Size: 775 Bytes

Versions: 5

Compression:

Stored size: 775 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

5 entries across 5 versions & 1 rubygems

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