Class: MotionConfigVars::HashlikeObjectConfigurer
- Inherits:
-
Object
- Object
- MotionConfigVars::HashlikeObjectConfigurer
- Defined in:
- lib/motion-config-vars/embed/hashlike_object_configurer.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ HashlikeObjectConfigurer
constructor
A new instance of HashlikeObjectConfigurer.
- #perform! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HashlikeObjectConfigurer
Returns a new instance of HashlikeObjectConfigurer.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/motion-config-vars/embed/hashlike_object_configurer.rb', line 4 def initialize ={} @hashlike_object = [:hashlike_object] raise ArgumentError, "'hashlike_object' missing" unless @hashlike_object @config_vars_data = [:config_vars_data] raise ArgumentError, "'config_vars_data' missing" unless @config_vars_data @config_name_for_facet_named = [:config_name_for_facet_named] raise ArgumentError, "'config_name_for_facet_named' missing" unless @config_name_for_facet_named self.validate_config_name_for_facet_named_is_closure self.validate_hashlike_object_is_hashlike self.validate_all_configured_facets_are_requested self.validate_all_facets_requested_configurations_available end |
Instance Method Details
#perform! ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/motion-config-vars/embed/hashlike_object_configurer.rb', line 17 def perform! self.requested_facets_names.each do |requested_facet_name| configuration_name = @config_name_for_facet_named.call requested_facet_name self.set requested_facet_name, configuration_name facet_data = @config_vars_data[requested_facet_name] return unless facet_data.is_a? Hash configuration_data = facet_data[configuration_name] configuration_data.each { |key, value| self.set key, value } end end |