lyonrb / wishlist

Meetup talks scheduler
https://github.com/lyonrb/wishlist/issues
7 stars 0 forks source link

Introducing `rb_import` #38

Closed franckverrot closed 9 years ago

franckverrot commented 9 years ago

During this talk, I'll introduce you to the rb_import gem.

This gem brings a new method import to your Ruby VM so that you can load classes without polluting the global VM constant table:

module MyModule
  SomeModel = import './some_model.rb' # => SomeModel is at the top-level
  class Foo
    SomeModel.new.blablabla
  end
end

another example:

module Foo
  Bar = import '/path/to/bar.rb' # this file defines a Bar class
end

Bar.new      # => NameError: uninitialized constant Bar
Foo::Bar.new # => #<Foo::Bar:0x0000000206a390>
franckverrot commented 9 years ago

I'll be attending LeWeb next week, so I'm proposing this for the first meetup of 2k15.

franckverrot commented 9 years ago

This one's done at http://www.meetup.com/Lyon-Ruby-Brigade/events/222242994/