Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/vendor/puppet/util/zaml.rb,
lib/vendor/puppet/util/metaid.rb,
lib/vendor/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb,
lib/vendor/puppet/util/monkey_patches.rb
Overview
We need this because the RAL uses ‘should’ as a method. This allows us the same behaviour but with a different method name.
Instance Method Summary collapse
- #assert_that(message = nil) ⇒ Object
-
#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
#assert_that(message = nil) ⇒ Object
69 70 71 72 73 |
# File 'lib/vendor/puppet/util/monkey_patches.rb', line 69 def assert_that( = nil) unless yield raise Exception.new("Assertion failure: #{}") end end |
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class
17 18 19 |
# File 'lib/vendor/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.
58 59 60 |
# File 'lib/vendor/puppet/util/monkey_patches.rb', line 58 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/vendor/puppet/util/metaid.rb', line 7 def (name, &blk) { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
4 |
# File 'lib/vendor/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/vendor/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/vendor/puppet/util/metaid.rb', line 3 def singleton_class; class << self; self; end; end |
#to_yaml_properties ⇒ Object
174 175 176 |
# File 'lib/vendor/puppet/util/zaml.rb', line 174 def to_yaml_properties instance_variables # default YAML behaviour. end |
#to_zaml(z) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/vendor/puppet/util/zaml.rb', line 184 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[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
177 178 179 |
# File 'lib/vendor/puppet/util/zaml.rb', line 177 def yaml_property_munge(x) x end |