Sha256: 743e352bafe01eab6722b4528446082b5c03b4c33c3b6df7af94b62809b4f7c3

Contents?: true

Size: 352 Bytes

Versions: 2

Compression:

Stored size: 352 Bytes

Contents

require 'facets/kernel/meta_class'

module Kernel

  # Add method to a meta-class --i.e. a singleton method.
  #
  #   class X; end
  #   X.meta_def(:x){"x"}
  #   X.x  #=> "x"
  #
  # CREDIT: WhyTheLuckyStiff

  def meta_def( name, &block )
    meta_class do
      define_method( name, &block )
    end
  end

  alias_method :metadef, :meta_def

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/kernel/meta_def.rb
facets-2.8.3 lib/core/facets/kernel/meta_def.rb