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(options = {}, item_factory: ItemFactory.new, **options2) ⇒ 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(options = {}, item_factory: ItemFactory.new, **options2) ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 |
# File 'lib/active_triples/configuration.rb', line 16 def initialize( = {}, item_factory: ItemFactory.new, **) @item_factory = item_factory @inner_hash = Hash[.to_a + .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
55 56 57 |
# File 'lib/active_triples/configuration.rb', line 55 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.
44 45 46 47 48 49 |
# 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 |
#merge(options) ⇒ ActiveTriples::Configuration
Merges this configuration with other configuration options. This uses reflection setters to handle special cases like :type.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_triples/configuration.rb', line 28 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.
65 66 67 |
# File 'lib/active_triples/configuration.rb', line 65 def to_h inner_hash.slice(*) end |