Sha256: d410ad495222426b2ecb60d6eb7ee8ffc67be1da7b5d271fa4d64b2b26284bf2
Contents?: true
Size: 608 Bytes
Versions: 45
Compression:
Stored size: 608 Bytes
Contents
require 'active_support/core_ext/string/inflections' module DefineClass def define_class(name, parent_class=nil, &block) before(:each) do Thread.current[:"#{name}_scopes"] = nil Object.send(:remove_const, name) if Object.const_defined?(name) case parent_class when Class klass = Class.new(parent_class) when String, Symbol klass = Class.new(parent_class.to_s.constantize) when nil klass = Class.new end Object.const_set(name, klass) klass.class_eval(&block) if block_given? klass end end end
Version data entries
45 entries across 45 versions & 1 rubygems