Class: Glossarist::Config
- Inherits:
-
Object
- Object
- Glossarist::Config
- Includes:
- Singleton
- Defined in:
- lib/glossarist/config.rb
Constant Summary collapse
- DEFAULT_CLASSES =
{ localized_concept: Glossarist::LocalizedConcept, managed_concept: Glossarist::ManagedConcept, }.freeze
Instance Attribute Summary collapse
-
#registered_classes ⇒ Object
readonly
Returns the value of attribute registered_classes.
Class Method Summary collapse
- .class_for(name) ⇒ Object
- .extension_attributes ⇒ Object
- .register_class(class_name, klass) ⇒ Object
- .register_extension_attributes(attributes) ⇒ Object
Instance Method Summary collapse
- #class_for(name) ⇒ Object
- #extension_attributes ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #register_class(class_name, klass) ⇒ Object
- #register_extension_attributes(attributes) ⇒ Object
Constructor Details
#initialize ⇒ Config
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/glossarist/config.rb', line 16 def initialize if File.exist?("glossarist.yaml") @config = YAML.load_file("glossarist.yaml") end @config ||= {} @registered_classes = DEFAULT_CLASSES.dup @extension_attributes = @config["extension_attributes"] || [] end |
Instance Attribute Details
#registered_classes ⇒ Object (readonly)
Returns the value of attribute registered_classes.
14 15 16 |
# File 'lib/glossarist/config.rb', line 14 def registered_classes @registered_classes end |
Class Method Details
.class_for(name) ⇒ Object
44 45 46 |
# File 'lib/glossarist/config.rb', line 44 def class_for(name) instance.class_for(name) end |
.extension_attributes ⇒ Object
48 49 50 |
# File 'lib/glossarist/config.rb', line 48 def extension_attributes instance.extension_attributes end |
.register_class(class_name, klass) ⇒ Object
52 53 54 |
# File 'lib/glossarist/config.rb', line 52 def register_class(class_name, klass) instance.register_class(class_name, klass) end |
.register_extension_attributes(attributes) ⇒ Object
56 57 58 |
# File 'lib/glossarist/config.rb', line 56 def register_extension_attributes(attributes) instance.register_extension_attributes(attributes) end |
Instance Method Details
#class_for(name) ⇒ Object
27 28 29 |
# File 'lib/glossarist/config.rb', line 27 def class_for(name) @registered_classes[name.to_sym] end |
#extension_attributes ⇒ Object
35 36 37 |
# File 'lib/glossarist/config.rb', line 35 def extension_attributes @extension_attributes end |
#register_class(class_name, klass) ⇒ Object
31 32 33 |
# File 'lib/glossarist/config.rb', line 31 def register_class(class_name, klass) @registered_classes[class_name.to_sym] = klass end |
#register_extension_attributes(attributes) ⇒ Object
39 40 41 |
# File 'lib/glossarist/config.rb', line 39 def register_extension_attributes(attributes) @extension_attributes = attributes end |