Class: MetaModule::MModule

Inherits:
Module
  • Object
show all
Defined in:
lib/meta_module.rb

Overview

subclassing of mmodule sort of sucks? use mixin with anonymous module instead?

Defined Under Namespace

Modules: Methods

Class Method Summary collapse

Class Method Details

.new ⇒ Object

I use .new so don't bother user to use super in #initialize



9
10
11
# File 'lib/meta_module.rb', line 9

def self.new(*)
  super.tap { |x| x.send :include, self::Methods }
end

.used(&block) ⇒ Object



13
14
15
16
# File 'lib/meta_module.rb', line 13

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