Class: ActiveTriples::Configuration
- Inherits:
-
Object
- Object
- ActiveTriples::Configuration
- Defined in:
- lib/active_triples/configuration.rb,
lib/active_triples/configuration/item.rb,
lib/active_triples/configuration/merge_item.rb,
lib/active_triples/configuration/item_factory.rb
Overview
Class which contains configuration for RDFSources.
Defined Under Namespace
Classes: Item, ItemFactory, MergeItem
Instance Attribute Summary collapse
-
#inner_hash ⇒ Object
Returns the value of attribute inner_hash.
Instance Method Summary collapse
-
#[](value) ⇒ Object
Returns the configured value for an option.
-
#initialize(item_factory: ItemFactory.new, **options) ⇒ Configuration
constructor
A new instance of Configuration.
-
#items ⇒ Hash{Symbol => ActiveTriples::Configuration::Item}
Returns a hash with keys as the configuration property and values as reflections which know how to set a new value to it.
-
#merge(options) ⇒ ActiveTriples::Configuration
Merges this configuration with other configuration options.
-
#to_h ⇒ Hash{Symbol => String, ::RDF::URI}
Returns the available configured options as a hash.
Constructor Details
#initialize(item_factory: ItemFactory.new, **options) ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 |
# File 'lib/active_triples/configuration.rb', line 15 def initialize(item_factory: ItemFactory.new, **) @item_factory = item_factory @inner_hash = Hash[.to_a] end |
Instance Attribute Details
#inner_hash ⇒ Object
Returns the value of attribute inner_hash.
10 11 12 |
# File 'lib/active_triples/configuration.rb', line 10 def inner_hash @inner_hash end |
Instance Method Details
#[](value) ⇒ Object
Returns the configured value for an option
54 55 56 |
# File 'lib/active_triples/configuration.rb', line 54 def [](value) to_h[value] end |
#items ⇒ Hash{Symbol => ActiveTriples::Configuration::Item}
Returns a hash with keys as the configuration property and values as reflections which know how to set a new value to it.
43 44 45 46 47 48 |
# 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 |
#merge(options) ⇒ ActiveTriples::Configuration
Merges this configuration with other configuration options. This uses reflection setters to handle special cases like :type.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_triples/configuration.rb', line 27 def merge() = .to_h new_config = self.class.new(**) new_config.items.each do |property, item| build_configuration_item(property).set item.value end self end |
#to_h ⇒ Hash{Symbol => String, ::RDF::URI}
Returns the available configured options as a hash.
This filters the options the class is initialized with.
64 65 66 |
# File 'lib/active_triples/configuration.rb', line 64 def to_h inner_hash.slice(*) end |