class ActiveTriples::Configuration
Class which contains configuration for RDFSources.
Constants
- CONFIG_OPTIONS
Attributes
Public Class Methods
@param item_factory
[ItemFactory] @param [Hash] options the configuration options. (Ruby 3+) @param [Hash] options2 the configuration options. (Ruby 2.x)
# File lib/active_triples/configuration.rb, line 16 def initialize(options = {}, item_factory: ItemFactory.new, **options2) @item_factory = item_factory @inner_hash = Hash[options.to_a + options2.to_a] end
Public Instance Methods
Returns the configured value for an option
@return the configured value
# File lib/active_triples/configuration.rb, line 55 def [](value) to_h[value] end
Returns a hash with keys as the configuration property and values as reflections which know how to set a new value to it.
@return [Hash{Symbol => ActiveTriples::Configuration::Item
}]
# File lib/active_triples/configuration.rb, line 44 def items to_h.each_with_object({}) do |config_value, hsh| key = config_value.first hsh[key] = build_configuration_item(key) end end
Merges this configuration with other configuration options. This uses reflection setters to handle special cases like :type.
@param [Hash] options configuration options to merge in. @return [ActiveTriples::Configuration] the configuration object which is a
result of merging.
# File lib/active_triples/configuration.rb, line 28 def merge(options) options = options.to_h new_config = self.class.new(options) new_config.items.each do |property, item| build_configuration_item(property).set item.value end self end
Returns the available configured options as a hash.
This filters the options the class is initialized with.
@return [Hash{Symbol => String, ::RDF::URI}]
# File lib/active_triples/configuration.rb, line 65 def to_h inner_hash.slice(*valid_config_options) end
Protected Instance Methods
# File lib/active_triples/configuration.rb, line 71 def build_configuration_item(key) item_factory.new(self, key) end
Private Instance Methods
# File lib/active_triples/configuration.rb, line 81 def valid_config_options CONFIG_OPTIONS end