Sha256: 9b516c9c9a14a30e59c592e98762f7d4ad248854a85efea19ab34f39da83f6ee

Contents?: true

Size: 403 Bytes

Versions: 4

Compression:

Stored size: 403 Bytes

Contents

# Creates a method that requires to be overridding.
# If it not overridden and called upon a TypeError
# will be raised.
#
#  require 'facet/module/abstract'
#
#  class C
#    abstract :a
#  end
#
#  c = C.new
#  c.a  #=> Error: undefined abstraction #a
#
class Module
  def abstract( *sym )
    sym.each { |s|
      define_method( s ) { raise TypeError, "undefined abstraction ##{s}" }
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet/module/abstract.rb
facets-0.7.0 lib/facet/module/abstract.rb
facets-0.7.1 lib/facet/module/abstract.rb
facets-0.7.2 lib/facet/module/abstract.rb