@steveklabnik Class.new with a block is useful for creating anonymous classes in tests, or as a simple mock mechanism.
-
-
-
@pete_higgins good call. embedding that tweet in the post ;) - Show replies
New conversation -
-
-
@steveklabnik you can create an object without calling initialize by calling MyClass.allocate -
@fowlduck is this ever useful for some reason? just wondering
- Show replies
New conversation -
-
-
@steveklabnik How about passing a block to Class.new and assigning to a variable, easy way to have anonymous test classes! - End of conversation
New conversation -
-
-
@steveklabnik I'd already known about it from poking around myself, but the thing about how Foo.new works is rather interesting. - End of conversation
New conversation -
-
-
@steveklabnik perusing@mattt’s rack-core-data project I liked the use of Class.new for scaffolding a Sinatra app https://github.com/mattt/rack-core-data/blob/master/lib/rack/core-data.rb#L15 … -
@andrewa2 neat! Thanks!
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.