Sha256: d804a87370e1431df60ea50eed8e672599a4e388eb12b9230e9e9c004d240aba

Contents?: true

Size: 280 Bytes

Versions: 3

Compression:

Stored size: 280 Bytes

Contents

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.8.2 lib/core/facets/kernel/meta_def.rb
facets-2.8.1 lib/core/facets/kernel/meta_def.rb
facets-2.8.0 lib/core/facets/kernel/meta_def.rb