Top Level Namespace

Defined Under Namespace

Modules: Sonar

Instance Method Summary collapse

Instance Method Details

#new_anon_class(parent, name = "", &proc) ⇒ Object

Creates an anonmyous throw-away class of type=parent, with an additional proc for defining methods on the class. Tnx @mccraigmccraig :-)



55
56
57
58
59
60
61
# File 'lib/sonar_connector/rspec/spec_helper.rb', line 55

def new_anon_class(parent, name="", &proc)
  klass = Class.new(parent)  
  mc = klass.instance_eval{ class << self ; self ; end }
  mc.send(:define_method, :to_s) {name}
  klass.class_eval(&proc) if proc
  klass
end