Module: Gearbox
- Defined in:
- lib/gearbox.rb,
lib/gearbox/type.rb,
lib/gearbox/types.rb,
lib/gearbox/attribute.rb,
lib/gearbox/vocabulary.rb,
lib/gearbox/rdf_collection.rb,
lib/gearbox/mixins/resource.rb,
lib/gearbox/attribute_collection.rb,
lib/gearbox/mixins/subject_methods.rb,
lib/gearbox/mixins/ad_hoc_properties.rb,
lib/gearbox/mixins/semantic_accessors.rb,
lib/gearbox/mixins/queryable_implementation.rb,
lib/gearbox/mixins/active_model_implementation.rb
Defined Under Namespace
Modules: ActiveModelImplementation, AdHocProperties, QueryableImplementation, Resource, SemanticAccessors, SubjectMethods, Type, Types Classes: Attribute, AttributeCollection, RDFCollection, Vocabulary
Class Method Summary collapse
-
.add_repository(name, klass, *args) ⇒ Void
Add a repository to Gearbox’s list of repositories.
-
.add_repository! ⇒ Void
Add a repository to Gearbox’s list of repositories.
-
.clear_repositories! ⇒ Void
Clear all repositories from Gearbox’s knowledge.
-
.path(path) ⇒ Object
= Helper Utility: path = ========================.
-
.repositories ⇒ Hash{Symbol => RDF::Repository}
= Settings from Spira = =======================.
-
.repository(name) ⇒ RDF::Repository
The RDF::Repository for the named repository.
-
.settings ⇒ Object
A thread-local hash for storing settings.
-
.type_alias(new, original) ⇒ Void
Alias a property type to another.
-
.types ⇒ Hash{Symbol => Gearbox::Type}
The list of all property types available for Gearbox resources.
Class Method Details
.add_repository(name, repo) ⇒ Void .add_repository(name, klass, *args) ⇒ Void
Add a repository to Gearbox’s list of repositories.
61 62 63 64 65 66 67 68 69 70 71 |
# 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 |
.add_repository(name, repo) ⇒ Void .add_repository(name, klass, *args) ⇒ Void
Add a repository to Gearbox’s list of repositories.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gearbox.rb', line 72 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_repositories! ⇒ Void
Clear all repositories from Gearbox’s knowledge. Use it if you want, but it’s really here for testing.
92 93 94 |
# File 'lib/gearbox.rb', line 92 def clear_repositories! settings[:repositories] = {} end |
.path(path) ⇒ Object
Helper Utility: path =
114 115 116 |
# File 'lib/gearbox.rb', line 114 def path(path) File.("../gearbox/#{path}", __FILE__) end |
.repositories ⇒ Hash{Symbol => RDF::Repository}
Settings from Spira =
The list of repositories available for Gearbox resources
19 20 21 |
# File 'lib/gearbox.rb', line 19 def repositories settings[:repositories] ||= {} end |
.repository(name) ⇒ RDF::Repository
The RDF::Repository for the named repository
81 82 83 |
# File 'lib/gearbox.rb', line 81 def repository(name) repositories[name] end |
.settings ⇒ Object
A thread-local hash for storing settings. Used by Resource classes.
40 41 42 |
# File 'lib/gearbox.rb', line 40 def settings Thread.current[:gearbox] ||= {} end |
.type_alias(new, original) ⇒ Void
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
105 106 107 |
# File 'lib/gearbox.rb', line 105 def type_alias(new, original) types[new] = original end |
.types ⇒ Hash{Symbol => Gearbox::Type}
The list of all property types available for Gearbox resources
29 30 31 |
# File 'lib/gearbox.rb', line 29 def types settings[:types] ||= {} end |