Sha256: 7c3242ded60a7302cb1e1201479d68c34f1126c3622d22eab5172f547736b74d
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
# Core ext methods class Object < BasicObject def stub_ivar(name, value = nil) instance_variable_set(name, value) yield ensure remove_instance_variable(name) end def stub_cvar(name, value = nil) class_variable_set(name, value) yield ensure remove_class_variable(name) end def stub_const(name, value) if const_defined?(name) old_value = const_get(name) remove_const(name) end const_set(name, value) yield ensure remove_const(name) const_set(name, old_value) if defined? old_value end def get_reset_ivar(name, *extra, &block) instance_variable_set(name, extra.first) if extra.any? instance_exec(&block) instance_variable_get(name).tap do remove_instance_variable(name) if instance_variable_defined?(name) end end def get_reset_cvar(name, *extra, &block) class_variable_set(name, extra.first) if extra.any? instance_exec(&block) class_variable_get(name).tap do remove_class_variable(name) if class_variable_defined?(name) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rails-graphql-0.1.3 | test/test_ext.rb |
rails-graphql-0.1.2 | test/test_ext.rb |
rails-graphql-0.1.1 | test/test_ext.rb |
rails-graphql-0.1.0 | test/test_ext.rb |