Class: MotionConfigVars::HashlikeObjectConfigurer

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-config-vars/embed/hashlike_object_configurer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HashlikeObjectConfigurer

Returns a new instance of HashlikeObjectConfigurer.

Raises:

  • (ArgumentError)


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 options={}
  @hashlike_object = options[:hashlike_object]
  raise ArgumentError, "'hashlike_object' missing" unless @hashlike_object
  @config_vars_data = options[:config_vars_data]
  raise ArgumentError, "'config_vars_data' missing" unless @config_vars_data
  @config_name_for_facet_named = options[: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