Sha256: 1ea6750120de427977c128dfb0f156694961488730e52306251fe4ed3e57f457
Contents?: true
Size: 935 Bytes
Versions: 5
Compression:
Stored size: 935 Bytes
Contents
require 'rdf' require 'rdf/vocabulary' require 'rdf/vocab' # Monkey-patch RDF::Vocab.each to load all vocabularies module RDF class Vocabulary class << self ## # Enumerates known RDF vocabulary classes. # # @yield [klass] # @yieldparam [Class] klass # @return [Enumerator] alias_method :_orig_each, :each def each(&block) # This is needed since all vocabulary classes are defined using # Ruby's autoloading facility, meaning that `@@subclasses` will be # empty until each subclass has been touched or require'd. RDF::Vocab::VOCABS.each do |n, params| class_name = params.fetch(:class_name, n.upcase).to_sym begin require "rdf/vocab/#{n}" rescue LoadError # Transient error warn "Failed to load #{n}" end end _orig_each(&block) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems