Sha256: ec22aca1647142bcec565f5eba44314a85c6ce4d6bc03578df9d3e895b647e82

Contents?: true

Size: 462 Bytes

Versions: 2

Compression:

Stored size: 462 Bytes

Contents

class Module
  def method_missing(method_name, *args, &block)
    @arg_sets ||= {}
    @arg_sets[method_name] = [args, block]
  end

  alias :tartan_included :included
  
  def included(klass)
    return unless defined? @arg_sets
    @arg_sets.each do |method, (args, block)|
      if klass.methods.include?(method.id2name)
        klass.send(method, *args, &block)
      else
        raise "method #{method} not defined in #{klass}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tartan-0.2.0 lib/core_ext/module.rb
tartan-0.2.1 lib/core_ext/module.rb