module Gearbox
Public Class Methods
Add a repository to Gearbox’s list of repositories.
@overload add_repository
(name, repo)
@param [Symbol] name The name of this repository @param [RDF::Repository] repo An RDF::Repository
@overload add_repository
(name, klass, *args)
@param [Symbol] name The name of this repository @param [RDF::Repository, Class] repo A Class that inherits from RDF::Repository @param [*Object] The list of arguments to instantiate the class
@example Adding an ntriples file as a repository
Gearbox.add_repository(:default, RDF::Repository.load('http://datagraph.org/jhacker/foaf.nt'))
@example Adding an empty repository to be instantiated on use
Gearbox.add_repository(:default, RDF::Repository)
@return [Void] @see RDF::Repository
# File lib/gearbox.rb, line 61 def add_repository(name, klass, *args) repositories[name] = case klass when Class promise { klass.new(*args) } else klass end if (name == :default) && settings[:repositories][name].nil? warn "WARNING: Adding nil default repository" end end
Clear all repositories from Gearbox’s knowledge. Use it if you want, but it’s really here for testing.
@return [Void] @private
# File lib/gearbox.rb, line 92 def clear_repositories! settings[:repositories] = {} end
The RDF::Repository for the named repository
@param [Symbol] name The name of the repository @return [RDF::Repository] @see RDF::Repository
# File lib/gearbox.rb, line 81 def repository(name) repositories[name] end
A thread-local hash for storing settings. Used by Resource
classes.
@see Gearbox::Resource
@see Gearbox.repositories
@see Gearbox.types
# File lib/gearbox.rb, line 40 def settings Thread.current[:gearbox] ||= {} end
Alias a property type to another. This allows a range of options to be specified for a property type which all reference one Gearbox::Type
@param [Any] new The new symbol or reference @param [Any] original The type the new symbol should refer to @return [Void] @private
# File lib/gearbox.rb, line 105 def type_alias(new, original) types[new] = original end
The list of all property types available for Gearbox
resources
@see Gearbox::Types
@return [Hash{Symbol => Gearbox::Type
}]
# File lib/gearbox.rb, line 29 def types settings[:types] ||= {} end
Private Instance Methods
Add a repository to Gearbox’s list of repositories.
@overload add_repository
(name, repo)
@param [Symbol] name The name of this repository @param [RDF::Repository] repo An RDF::Repository
@overload add_repository
(name, klass, *args)
@param [Symbol] name The name of this repository @param [RDF::Repository, Class] repo A Class that inherits from RDF::Repository @param [*Object] The list of arguments to instantiate the class
@example Adding an ntriples file as a repository
Gearbox.add_repository(:default, RDF::Repository.load('http://datagraph.org/jhacker/foaf.nt'))
@example Adding an empty repository to be instantiated on use
Gearbox.add_repository(:default, RDF::Repository)
@return [Void] @see RDF::Repository
# File lib/gearbox.rb, line 61 def add_repository(name, klass, *args) repositories[name] = case klass when Class promise { klass.new(*args) } else klass end if (name == :default) && settings[:repositories][name].nil? warn "WARNING: Adding nil default repository" end end
Clear all repositories from Gearbox’s knowledge. Use it if you want, but it’s really here for testing.
@return [Void] @private
# File lib/gearbox.rb, line 92 def clear_repositories! settings[:repositories] = {} end
The RDF::Repository for the named repository
@param [Symbol] name The name of the repository @return [RDF::Repository] @see RDF::Repository
# File lib/gearbox.rb, line 81 def repository(name) repositories[name] end
A thread-local hash for storing settings. Used by Resource
classes.
@see Gearbox::Resource
@see Gearbox.repositories
@see Gearbox.types
# File lib/gearbox.rb, line 40 def settings Thread.current[:gearbox] ||= {} end
Alias a property type to another. This allows a range of options to be specified for a property type which all reference one Gearbox::Type
@param [Any] new The new symbol or reference @param [Any] original The type the new symbol should refer to @return [Void] @private
# File lib/gearbox.rb, line 105 def type_alias(new, original) types[new] = original end
The list of all property types available for Gearbox
resources
@see Gearbox::Types
@return [Hash{Symbol => Gearbox::Type
}]
# File lib/gearbox.rb, line 29 def types settings[:types] ||= {} end