Class: Lafcadio::ContextualService
- Inherits:
-
Object
- Object
- Lafcadio::ContextualService
- Defined in:
- lib/lafcadio/util/ContextualService.rb
Overview
A ContextualService is a service that is managed by the Context. ContextualServices are not instantiated normally. Instead, the instance of such a service may be retrieved by calling the method
< class name >.get< class name >
For example: ObjectStore.getObjectStore
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(passKey) ⇒ ContextualService
constructor
The
passKey
needs to be the Context instance, or else this method fails.
Constructor Details
#initialize(passKey) ⇒ ContextualService
The passKey
needs to be the Context instance, or else this method fails. Note that this isn’t hard security of any kind; it’s simply a gentle reminder to users of a ContextualService that the class should not be instantiated directly.
24 25 26 27 28 29 30 31 |
# File 'lib/lafcadio/util/ContextualService.rb', line 24 def initialize(passKey) if passKey.class != Context raise ArgumentError, "#{ self.class.name.to_s } should only be instantiated by a " + "Context", caller end end |
Class Method Details
.method_missing(methodId) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/lafcadio/util/ContextualService.rb', line 11 def ContextualService.method_missing(methodId) methodName = methodId.id2name if methodName =~ /^get.*/ Context.instance.send(methodName) else super methodId end end |