spec/support/my_temp.rb in real_zip-0.0.8 vs spec/support/my_temp.rb in real_zip-0.2.0

- old
+ new

@@ -1,4 +1,30 @@ +class MetaModule < Module + # use .new so I don't bother user to use super in #initialize + def self.new(*) + super.tap { |x| x.send :include, self::Methods } + end + + def self.used &block + define_method :included, &block + define_method :extended, &block + end +end + + +class MetaModule2 #< Class + def self.new *params + _params = params.join ?, + a_params = params.map{|x|"@#{x}"}.join ?, + + Class.new(MetaModule) do + eval "def initialize(#{_params}); #{a_params} = #{_params} end" + private; attr_reader *params + end + end +end + + class MyTemp < MetaModule2.new :getter, :file used do |at| at.def_temp_file getter, file end \ No newline at end of file