Skip to content

Instantly share code, notes, and snippets.

@julik
Created July 5, 2011 14:14
Show Gist options
  • Save julik/1064909 to your computer and use it in GitHub Desktop.
Save julik/1064909 to your computer and use it in GitHub Desktop.
irb(main):010:0> self.class.const_set(:SomeClass,
irb(main):011:1* Class.new(Ancestor) do
irb(main):012:2* def initialize(var)
irb(main):013:3> print "#{self.class} initialized with #{var}"
irb(main):014:3> end
irb(main):015:2> end
irb(main):016:1> )
=> SomeClass
irb(main):017:0> SomeClass.new("foo")
SomeClass initialized with foo=> #<SomeClass:0x67b77c>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment