Class: Alchemy::Configuration::ClassOption

Inherits:
BaseOption
  • Object
show all
Defined in:
lib/alchemy/configuration/class_option.rb

Instance Attribute Summary

Attributes inherited from BaseOption

#name

Instance Method Summary collapse

Methods inherited from BaseOption

#==, #hash, #initialize, #raw_value, value_class

Constructor Details

This class inherits a constructor from Alchemy::Configuration::BaseOption

Instance Method Details

#allowed_classesObject



8
9
10
# File 'lib/alchemy/configuration/class_option.rb', line 8

def allowed_classes
  [String, Array]
end

#validate(value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/alchemy/configuration/class_option.rb', line 12

def validate(value)
  super

  if value.is_a?(Array)
    validate_array!(value)
  end
end

#valueObject



20
21
22
23
24
25
26
27
28
# File 'lib/alchemy/configuration/class_option.rb', line 20

def value
  @_cached_value ||= case @value
  when Array
    @value[0] = @value[0]&.constantize
    @value
  when String
    @value&.constantize
  end
end