From: Robert Klemme Date: 2008-01-22T19:47:35+09:00 Subject: Re: ruby wish-list 2008/1/21, Roger Pack : > Next wish for the magic lamp: > a command that does something like > module X > CONSTANT = '3' > def class_function > end > end > > class Y > extend_and_include_constants X # this one > end That's not too hard. All the ingredients are there already: irb(main):001:0> class Module irb(main):002:1> def your_extend(mod) irb(main):003:2> extend mod irb(main):004:2> mod.constants.each do |co| irb(main):005:3* const_set(co, mod.const_get(co)) irb(main):006:3> end irb(main):007:2> end irb(main):008:1> end => nil irb(main):009:0> module X irb(main):010:1> Foo = 2 irb(main):011:1> def mm; 1; end irb(main):012:1> end => nil irb(main):013:0> class Y irb(main):014:1> your_extend X irb(main):015:1> end => ["Foo"] irb(main):016:0> Y.mm => 1 irb(main):017:0> Y::Foo => 2 Cheers robert -- use.inject do |as, often| as.you_can - without end