Class: RDF::Lamprey::Config
- Inherits:
-
Object
- Object
- RDF::Lamprey::Config
- Defined in:
- app/lamprey.rb
Overview
Constant Summary collapse
- @@repositories =
{ default: RDF::Repository }
Instance Attribute Summary collapse
Class Method Summary collapse
- .configure!(**options) ⇒ Object
-
.register_repository!(name, klass) ⇒ void
Registers a repository for use with the #build_repository method.
Instance Method Summary collapse
-
#build_repository ⇒ RDF::Repository
Builds the repository as given in the configuration.
-
#configure! ⇒ void
Configures RDF::Lamprey with #options.
-
#initialize(repository: :default) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(repository: :default) ⇒ Config
Returns a new instance of Config.
94 95 96 97 |
# File 'app/lamprey.rb', line 94 def initialize(repository: :default) @options = {} @options[:repository] = repository end |
Instance Attribute Details
#options ⇒ Object
88 89 90 |
# File 'app/lamprey.rb', line 88 def @options end |
Class Method Details
.configure!(**options) ⇒ Object
67 68 69 |
# File 'app/lamprey.rb', line 67 def self.configure!(**) new(**).configure! end |
.register_repository!(name, klass) ⇒ void
This method returns an undefined value.
Registers a repository for use with the #build_repository method.
82 83 84 |
# File 'app/lamprey.rb', line 82 def self.register_repository!(name, klass) @@repositories[name] = klass end |
Instance Method Details
#build_repository ⇒ RDF::Repository
Builds the repository as given in the configuration.
103 104 105 106 107 108 109 110 111 |
# File 'app/lamprey.rb', line 103 def build_repository @@repositories.fetch([:repository]) do warn "#{[:repository]} is not a configured repository. Use "\ '`Lamprey::Config.register_repository!` to register it before '\ 'configuration. Falling back on the default: ' \ "#{@@repositories[:default]}." @@repositories[:default] end.new end |
#configure! ⇒ void
This method returns an undefined value.
Configures RDF::Lamprey with #options.
117 118 119 120 121 122 123 124 125 |
# File 'app/lamprey.rb', line 117 def configure! repository = build_repository unless repository.persistent? warn "#{repository} is not a persistent repository. "\ 'Data will be lost on server shutdown.' end RDF::Lamprey.configure { |config| config.set :repository, repository } end |