Class: Object

Inherits:
BasicObject
Defined in:
lib/puppet/util/metaid.rb,
lib/puppet/util/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object

Defines an instance method within a class



17
18
19
# File 'lib/puppet/util/metaid.rb', line 17

def class_def(name, &blk)
  class_eval { define_method name, &blk }
end

#daemonizeObject

ActiveSupport 2.3.x mixes in a dangerous method that can cause rspec to fork bomb and other strange things like that.

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/puppet/util/monkey_patches.rb', line 25

def daemonize
  raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it."
end

#meta_def(name, &blk) ⇒ Object

Adds methods to a singleton_class



7
8
9
# File 'lib/puppet/util/metaid.rb', line 7

def meta_def(name, &blk)
  meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



4
# File 'lib/puppet/util/metaid.rb', line 4

def meta_eval(&blk); singleton_class.instance_eval(&blk); end

#meta_undef(name, &blk) ⇒ Object

Remove singleton_class methods.



12
13
14
# File 'lib/puppet/util/metaid.rb', line 12

def meta_undef(name, &blk)
  meta_eval { remove_method name }
end

#singleton_classObject

The hidden singleton lurks behind everyone



3
# File 'lib/puppet/util/metaid.rb', line 3

def singleton_class; class << self; self; end; end