Class: AtlasEngine::ValidationTranscriber::Constants
- Inherits:
-
Object
- Object
- AtlasEngine::ValidationTranscriber::Constants
- Extended by:
- T::Sig
- Includes:
- Singleton
- Defined in:
- app/lib/atlas_engine/validation_transcriber/constants.rb
Constant Summary collapse
- TRANSCRIBER_FILE =
File.join(AtlasEngine::Engine.root, "db/data/transcriber.yml").freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Constants
constructor
A new instance of Constants.
- #known?(constant_type, value) ⇒ Boolean
Constructor Details
#initialize ⇒ Constants
Returns a new instance of Constants.
29 30 31 32 |
# File 'app/lib/atlas_engine/validation_transcriber/constants.rb', line 29 def initialize @data ||= load_yaml_file(TRANSCRIBER_FILE) self.class.create_accessor_methods(@data) end |
Class Method Details
.create_accessor_methods(yaml_hash) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/lib/atlas_engine/validation_transcriber/constants.rb', line 19 def create_accessor_methods(yaml_hash) yaml_hash.each do |constant_name, _| define_method(constant_name.to_s) do @data[constant_name] end end end |
.instance ⇒ Object
15 16 17 |
# File 'app/lib/atlas_engine/validation_transcriber/constants.rb', line 15 def instance @instance ||= new end |
Instance Method Details
#known?(constant_type, value) ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'app/lib/atlas_engine/validation_transcriber/constants.rb', line 35 def known?(constant_type, value) constants = @data[constant_type] return false if constants.blank? || value.blank? downcased = value.delete_suffix(".").downcase constants.key?(downcased.to_sym) || constants.value?(downcased) end |