Class: TaliaCore::DummyHandler
- Defined in:
- lib/talia_core/dummy_handler.rb
Overview
This is an internal class for “dummy handler invocations” on sources The problem is that invocations like source.namespace::name are evaluated to (source.namespace).name This means that source.namespace must return an object on which “name” can be called with the desired effect. This object is the “dummy handler”
Instance Method Summary collapse
-
#initialize(namespace, subject) ⇒ DummyHandler
constructor
Create the new handler.
-
#method_missing(method, *args) ⇒ Object
Catch the invocations.
Constructor Details
#initialize(namespace, subject) ⇒ DummyHandler
Create the new handler
17 18 19 20 21 22 23 |
# File 'lib/talia_core/dummy_handler.rb', line 17 def initialize(namespace, subject) assit_kind_of(N::URI, namespace) assit_kind_of(TaliaCore::Source, subject) @namespace = namespace.to_s @subject = subject end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Catch the invocations
26 27 28 29 30 |
# File 'lib/talia_core/dummy_handler.rb', line 26 def method_missing(method, *args) # read value raise(ArgumentError, "Wrong number of arguments") if(args.size != 0) @subject[@namespace + method.to_s] end |