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.
# File lib/active_triples/configuration.rb, line 15 def initialize(item_factory: ItemFactory.new, **options) @item_factory = item_factory @inner_hash = Hash[options.to_a] end
Public Instance Methods
Returns the configured value for an option
@return the configured value
# File lib/active_triples/configuration.rb, line 54 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 43 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 27 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 64 def to_h inner_hash.slice(*valid_config_options) end
Protected Instance Methods
# File lib/active_triples/configuration.rb, line 70 def build_configuration_item(key) item_factory.new(self, key) end
Private Instance Methods
# File lib/active_triples/configuration.rb, line 80 def valid_config_options CONFIG_OPTIONS end