Sha256: a7310f18fb979a9930a4b68086e510196b375ac8c0567c73fc869ed3dc79d806

Contents?: true

Size: 365 Bytes

Versions: 11

Compression:

Stored size: 365 Bytes

Contents

class Module
  def required(name, message=nil)
    message ||= "You need to implement method #{name}"
    define_method name do |*|
      raise message
    end
  end

  def patch(method_name, &block)
    method_proc = instance_method method_name

    define_method method_name do |*args|
      instance_exec(*args, method_proc.bind(self), &block)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mumukit-core-1.13.0 lib/mumukit/core/module.rb
mumukit-core-1.12.0 lib/mumukit/core/module.rb
mumukit-core-1.11.0 lib/mumukit/core/module.rb
mumukit-core-1.10.1 lib/mumukit/core/module.rb
mumukit-core-1.10.0 lib/mumukit/core/module.rb
mumukit-core-1.9.0 lib/mumukit/core/module.rb
mumukit-core-1.8.0 lib/mumukit/core/module.rb
mumukit-core-1.7.0 lib/mumukit/core/module.rb
mumukit-core-1.6.0 lib/mumukit/core/module.rb
mumukit-core-1.5.2 lib/mumukit/core/module.rb
mumukit-core-1.5.1 lib/mumukit/core/module.rb