Module: SmartEnum::YamlStore
- Included in:
- SmartEnum
- Defined in:
- lib/smart_enum/yaml_store.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.data_root ⇒ Object
21 22 23 |
# File 'lib/smart_enum/yaml_store.rb', line 21 def self.data_root @data_root end |
.data_root=(val) ⇒ Object
25 26 27 |
# File 'lib/smart_enum/yaml_store.rb', line 25 def self.data_root=(val) @data_root = val end |
Instance Method Details
#register_values_from_file! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smart_enum/yaml_store.rb', line 7 def register_values_from_file! unless SmartEnum::YamlStore.data_root raise "Must set SmartEnum::YamlStore.data_root before using `register_values_from_file!`" end unless self.name raise "Cannot infer data file for anonymous class" end filename = "#{SmartEnum::Utilities.tableize(self.name)}.yml" file_path = File.join(SmartEnum::YamlStore.data_root, filename) values = YAML.load_file(file_path) register_values(values, self, detect_sti_types: true) end |