Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/mumuki/domain/extensions/module.rb

Overview

TODO move to mumukit-core

Instance Method Summary collapse

Instance Method Details

#define_once(selector, *args, &block) ⇒ Object



13
14
15
16
# File 'lib/mumuki/domain/extensions/module.rb', line 13

def define_once(selector, *args, &block)
  ensure_undefined! selector
  define_method selector, *args, &block
end

#ensure_defined!(selector) ⇒ Object



3
4
5
6
# File 'lib/mumuki/domain/extensions/module.rb', line 3

def ensure_defined!(selector)
  # FIXME pass additional false flag in ruby 2.6
  raise "method #{selector} was not previously defined here" unless method_defined?(selector)
end

#ensure_undefined!(selector) ⇒ Object



8
9
10
11
# File 'lib/mumuki/domain/extensions/module.rb', line 8

def ensure_undefined!(selector)
  # FIXME pass additional false flag in ruby 2.6
  raise "method #{selector} was previously defined here" if method_defined?(selector)
end