Sha256: 63551027b726cb38afa29891caf9070088d42e6855b8b200d68efa3302fbe882

Contents?: true

Size: 593 Bytes

Versions: 4

Compression:

Stored size: 593 Bytes

Contents

class Object
    # The hidden singleton lurks behind everyone
    def metaclass; class << self; self; end; end
    def meta_eval(&blk); metaclass.instance_eval(&blk); end

    # Adds methods to a metaclass
    def meta_def(name, &blk)
        meta_eval { define_method name, &blk }
    end

    # Remove metaclass methods.
    def meta_undef(name, &blk)
        meta_eval { remove_method name }
    end

    # Defines an instance method within a class
    def class_def(name, &blk)
        class_eval { define_method name, &blk }
    end
end

# $Id: metaid.rb 1504 2006-08-28 16:30:49Z luke $

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-0.22.4 lib/puppet/util/metaid.rb
puppet-0.23.0 lib/puppet/util/metaid.rb
puppet-0.23.2 lib/puppet/util/metaid.rb
puppet-0.23.1 lib/puppet/util/metaid.rb