Sha256: 92287c10f5afd9ca2899b1fec9ef61f0efad9ed75c68664e6e7a1eae11f06d7f

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 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.
  #
  # 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.7.0 lib/core/facets/kernel/instance_class.rb
facets-2.6.0 lib/core/facets/kernel/instance_class.rb
facets-2.5.1 lib/core/facets/kernel/instance_class.rb
facets-2.5.0 lib/core/facets/kernel/instance_class.rb
facets-2.5.2 lib/core/facets/kernel/instance_class.rb