Class: Applitools::AbstractConfiguration

Inherits:
Object
  • Object
show all
Extended by:
EyesConfigurationDSL
Defined in:
lib/applitools/core/abstract_configuration.rb

Direct Known Subclasses

EyesBaseConfiguration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EyesConfigurationDSL

accessor_methods, boolean_field, collect_method, enum_field, int_field, methods_to_delegate, object_field, string_field

Constructor Details

#initializeAbstractConfiguration

Returns a new instance of AbstractConfiguration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/applitools/core/abstract_configuration.rb', line 11

def initialize
  @config_hash = {}
  self.validation_errors = {}
  if self.class.respond_to? :default_config
    default_config = self.class.default_config
    default_config.keys.each do |k|
      unless default_config[k].nil?
        send "#{k}=", default_config[k].deep_clone if default_config[k].respond_to?(:deep_clone)
        send "#{k}=", default_config[k].clone if default_config[k].respond_to?(:clone)
        send "#{k}=", default_config[k].clone unless default_config[k].respond_to?(:clone) || default_config[k].respond_to?(:deep_clone)
      end
    end
  end
end

Instance Attribute Details

#config_hashObject (readonly)

Returns the value of attribute config_hash.



7
8
9
# File 'lib/applitools/core/abstract_configuration.rb', line 7

def config_hash
  @config_hash
end

#validation_errorsObject

Returns the value of attribute validation_errors.



8
9
10
# File 'lib/applitools/core/abstract_configuration.rb', line 8

def validation_errors
  @validation_errors
end

Instance Method Details

#deep_cloneObject Also known as: deep_dup



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/applitools/core/abstract_configuration.rb', line 26

def deep_clone
  new_config = self.class.new
  config_keys.each do |k|
    new_config.send(
      "#{k}=", case value = send(k)
               when Symbol, FalseClass, TrueClass, Integer, Float, NilClass
                 value
               else
                 value.clone
               end
    )
  end
  new_config
end