Class: TooShort::ClassRegistry
- Inherits:
-
Object
- Object
- TooShort::ClassRegistry
- Includes:
- Singleton
- Defined in:
- lib/too_short.rb
Overview
Holds the model classes that use TooShort It’s basically a map storing :scope => :class_name I.e. ‘p’ => ‘Post’
Only used internally.
Instance Method Summary collapse
-
#clear ⇒ Object
only used for specs.
- #lookup(class_scope) ⇒ Object
- #register(class_name, class_scope) ⇒ Object
- #registry ⇒ Object
Instance Method Details
#clear ⇒ Object
only used for specs
70 71 72 |
# File 'lib/too_short.rb', line 70 def clear @registry = {} end |
#lookup(class_scope) ⇒ Object
65 66 67 |
# File 'lib/too_short.rb', line 65 def lookup(class_scope) registry[class_scope] end |
#register(class_name, class_scope) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/too_short.rb', line 57 def register(class_name, class_scope) registered_class_name = registry[class_scope] if registered_class_name && registered_class_name != class_name raise TooShortInvalidOptionError.new("Duplicate usage of scope '#{class_scope.to_s}', used in classes #{registered_class_name} and #{class_name}") end registry[class_scope] = class_name end |
#registry ⇒ Object
53 54 55 |
# File 'lib/too_short.rb', line 53 def registry @registry ||= {} end |