Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/puppet/util/zaml.rb,
lib/puppet/util/metaid.rb,
lib/puppet/util/monkey_patches.rb
Overview
Behavior for custom classes
Instance Method Summary collapse
-
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class.
-
#daemonize ⇒ Object
ActiveSupport 2.3.x mixes in a dangerous method that can cause rspec to fork bomb and other strange things like that.
-
#meta_def(name, &blk) ⇒ Object
Adds methods to a singleton_class.
- #meta_eval(&blk) ⇒ Object
-
#meta_undef(name, &blk) ⇒ Object
Remove singleton_class methods.
-
#singleton_class ⇒ Object
The hidden singleton lurks behind everyone.
- #to_yaml_properties ⇒ Object
- #to_zaml(z) ⇒ Object
- #yaml_property_munge(x) ⇒ Object
- #zamlized_class_name(root) ⇒ Object
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 |
#daemonize ⇒ Object
ActiveSupport 2.3.x mixes in a dangerous method that can cause rspec to fork bomb and other strange things like that.
64 65 66 |
# File 'lib/puppet/util/monkey_patches.rb', line 64 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 (name, &blk) { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
4 |
# File 'lib/puppet/util/metaid.rb', line 4 def (&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 (name, &blk) { remove_method name } end |
#singleton_class ⇒ Object
The hidden singleton lurks behind everyone
3 |
# File 'lib/puppet/util/metaid.rb', line 3 def singleton_class; class << self; self; end; end |
#to_yaml_properties ⇒ Object
178 179 180 |
# File 'lib/puppet/util/zaml.rb', line 178 def to_yaml_properties instance_variables.map(&:to_sym) end |
#to_zaml(z) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/puppet/util/zaml.rb', line 196 def to_zaml(z) z.first_time_only(self) { z.emit(zamlized_class_name(Object)) z.nested { instance_variables = to_yaml_properties if instance_variables.empty? z.emit(" {}") else instance_variables.each { |v| z.nl v.to_s[1..-1].to_zaml(z) # Remove leading '@' z.emit(': ') yaml_property_munge(instance_variable_get(v)).to_zaml(z) } end } } end |
#yaml_property_munge(x) ⇒ Object
187 188 189 |
# File 'lib/puppet/util/zaml.rb', line 187 def yaml_property_munge(x) x end |