Sha256: 090dfedeadef8bbab3eea0d0e911878304208e4ea3a02fa3d087e0af68c9cd64
Contents?: true
Size: 704 Bytes
Versions: 1
Compression:
Stored size: 704 Bytes
Contents
require_relative "inhelint/version" module Inhelint class Error < StandardError; end class Lint < Module def initialize(level: 2, handler: nil) super() @level = level @handler = handler end def included(base) level = @level handler = @handler || proc { raise Error, "Inheritance level too deep: #{level}" } inherited = proc do |klass| if klass.ancestors.count { |a| a.is_a?(Class) && a <= base } > level handler.call(klass) else klass.define_singleton_method(:inherited, inherited) end end inherited[base] end alias prepended included end Default = Lint.new.freeze # Shortcut end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inhelint-1.0.0 | lib/inhelint.rb |