Sha256: cf67eca748dee6097f3e076e30826e096aeaa73a4ac3f65d9fd928471e9cf175
Contents?: true
Size: 901 Bytes
Versions: 1
Compression:
Stored size: 901 Bytes
Contents
require "meta_module/version" module MetaModule # subclassing of mmodule sort of sucks? # use mixin with anonymous module instead? class MModule < Module # I use .new so 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 eval 'define_method :extended, &block' # to hide this line from mutant! # define_method :extended # because this works too! with some warnings though:) end module Methods # monkey patch me... end end class MModule2 # < Class ... def self.new *params _params = params.join ?, a_params = params.map { |x| "@#{x}" }.join ?, Class.new(MModule) do eval "def initialize(#{_params}); #{a_params} = #{_params} end" #private attr_reader *params end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
meta_module-0.0.1 | lib/meta_module.rb |