Class: Cda::TemplatesRegistry
- Inherits:
-
Object
- Object
- Cda::TemplatesRegistry
- Defined in:
- lib/cda/templates_registry.rb
Direct Known Subclasses
Instance Method Summary collapse
- #[](template_id) ⇒ Object
- #add(template_id, model_class) ⇒ Object
-
#initialize(mappings = {}) ⇒ TemplatesRegistry
constructor
A new instance of TemplatesRegistry.
Constructor Details
#initialize(mappings = {}) ⇒ TemplatesRegistry
Returns a new instance of TemplatesRegistry.
2 3 4 |
# File 'lib/cda/templates_registry.rb', line 2 def initialize(mappings = {}) @collection = mappings end |
Instance Method Details
#[](template_id) ⇒ Object
13 14 15 |
# File 'lib/cda/templates_registry.rb', line 13 def [](template_id) @collection[template_id] end |
#add(template_id, model_class) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/cda/templates_registry.rb', line 6 def add(template_id, model_class) raise ArgumentError, "template_id is nil" unless template_id raise "Already registered #{template_id}, #{model_class}" if @collection.key?(template_id) @collection[template_id] = model_class end |