Sha256: 106a82049e6342578fc9ddef27963072f0435342d2cd5f948e87e56defec8772

Contents?: true

Size: 261 Bytes

Versions: 1

Compression:

Stored size: 261 Bytes

Contents

def define_class(name, superclass = Object, &block)
  name = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  eval("class #{name} < #{superclass}; end")
  clazz = eval(name)
  clazz.class_eval(&block) if block_given?
  clazz
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
defined-by-0.0.5 lib/defined-by/define_class.rb