Class: TypeWrapper::Module

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

Direct Known Subclasses

Forwarding

Defined Under Namespace

Modules: Refines

Instance Method Summary collapse

Constructor Details

#initialize(default = Object, *types, &blk) ⇒ Module

Returns a new instance of Module.



24
25
26
27
28
29
30
# File 'lib/type_wrapper/module.rb', line 24

def initialize(default = Object, *types, &blk)
  mod, @block = self, blk
  types.unshift(default).each do |type|
    refine(type) { module_exec mod, &blk }
  end
  super(&blk)
end

Instance Method Details

#refines(*types) ⇒ Object Also known as: []



32
33
34
# File 'lib/type_wrapper/module.rb', line 32

def refines(*types)
  self.class.new(*types, &@block)
end