Class: Waylon::SenseRegistry
- Inherits:
-
Object
- Object
- Waylon::SenseRegistry
- Includes:
- Singleton
- Defined in:
- lib/waylon/sense_registry.rb
Overview
Registry of Sense subclasses known to Waylon
Instance Attribute Summary collapse
-
#senses ⇒ Object
readonly
Returns the value of attribute senses.
Class Method Summary collapse
-
.register(name, class_name) ⇒ Class
A convenience wrapper around the singleton instance #register method.
Instance Method Summary collapse
-
#register(name, class_name) ⇒ Class
Add the provided Sense class to the registry under ‘name`.
-
#to_hash ⇒ Hash
Provides a Hash version of this registry.
Instance Attribute Details
#senses ⇒ Object (readonly)
Returns the value of attribute senses.
8 9 10 |
# File 'lib/waylon/sense_registry.rb', line 8 def senses @senses end |
Class Method Details
.register(name, class_name) ⇒ Class
A convenience wrapper around the singleton instance #register method
13 14 15 |
# File 'lib/waylon/sense_registry.rb', line 13 def self.register(name, class_name) instance.register(name, class_name) end |
Instance Method Details
#register(name, class_name) ⇒ Class
Add the provided Sense class to the registry under ‘name`
21 22 23 24 |
# File 'lib/waylon/sense_registry.rb', line 21 def register(name, class_name) @senses ||= {} @senses[name.to_s] = class_name end |
#to_hash ⇒ Hash
Provides a Hash version of this registry
28 29 30 |
# File 'lib/waylon/sense_registry.rb', line 28 def to_hash (@senses || {}).dup end |