Class: TranslationDiff::Registry
- Inherits:
-
Object
- Object
- TranslationDiff::Registry
- Defined in:
- lib/translation_diff/registry.rb
Overview
Maps a symbol to a class that builds itself from a Configuration; the whole contract is answering build(config).
Instance Method Summary collapse
- #build(name, config) ⇒ Object
- #classes ⇒ Object
-
#initialize(kind) ⇒ Registry
constructor
kindappears in the unknown-name error message, so it should be a singular noun: "provider". - #names ⇒ Object
- #register(name, klass) ⇒ Object
- #registered?(name) ⇒ Boolean
Constructor Details
#initialize(kind) ⇒ Registry
kind appears in the unknown-name error message, so it should be a singular noun: "provider".
4 5 6 7 |
# File 'lib/translation_diff/registry.rb', line 4 def initialize(kind) @kind = kind @entries = {} end |
Instance Method Details
#build(name, config) ⇒ Object
13 14 15 |
# File 'lib/translation_diff/registry.rb', line 13 def build(name, config) fetch(name).build(config) end |
#classes ⇒ Object
21 |
# File 'lib/translation_diff/registry.rb', line 21 def classes = @entries.values |
#names ⇒ Object
19 |
# File 'lib/translation_diff/registry.rb', line 19 def names = @entries.keys |
#register(name, klass) ⇒ Object
9 10 11 |
# File 'lib/translation_diff/registry.rb', line 9 def register(name, klass) @entries[name.to_sym] = klass end |
#registered?(name) ⇒ Boolean
17 |
# File 'lib/translation_diff/registry.rb', line 17 def registered?(name) = @entries.key?(name.to_sym) |