Sha256: 36d1eb124312bb428f91cf2cf95641d8de85bfd1ba1cbee2f19a4c2f66a02405
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
#-- # Uninheritable # # Copyright (c) 2003 Austin Ziegler # # Ruby License # # This module is free software. You may use, modify, and/or redistribute this # software under the same terms as Ruby. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. # # ========================================================================== # Revision History # ========================================================================== # # 2003.9.17 Austin Ziegler # - Minor modifications to documentation. # # ========================================================================== #++ #:title: Uninheritable # # Allows an object to declare itself as unable to be subclassed. The # technique behind this is very simple (redefinition of #inherited), so this # just provides an easier way to do the same thing with a consistent error # message. # # == Usage # # require 'mega/uninheritable' # # class A # extend Uninheritable # end # # class B < A; end # => raises TypeError # # == Author(s) # # * Austin Ziegler # module Uninheritable # Redefines a class's #inherited definition to prevent subclassing of the # class extended by this module. def inherited(klass) raise TypeError, "Class #{self} cannot be subclassed." end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mega-0.3.1 | lib/mega/uninheritable.rb |