Class: ThreadPartyProxy
- Inherits:
-
Object
- Object
- ThreadPartyProxy
- Defined in:
- lib/threadparty/threadpartyproxy.rb
Overview
The DSL resolver for ThreadParty.
It handles adding classes that inherited PartyProxy to the DSL, and executing them
Constant Summary collapse
- @@proxables =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pool_party) ⇒ ThreadPartyProxy
constructor
A new instance of ThreadPartyProxy.
- #method_missing(name, *args, &block) ⇒ Object
- #perform_proxy(a_class, &block) ⇒ Object
Constructor Details
#initialize(pool_party) ⇒ ThreadPartyProxy
Returns a new instance of ThreadPartyProxy.
13 14 15 |
# File 'lib/threadparty/threadpartyproxy.rb', line 13 def initialize(pool_party) @thread_party = pool_party end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/threadparty/threadpartyproxy.rb', line 21 def method_missing(name, *args, &block) if @@proxables.has_key?(name) then perform_proxy(name, &block) else raise ArgumentError, "The bouncer says \"#{name}\" is not allowed at the thread party.\nIt is not inherited from PartyProxy" end end |
Class Method Details
.add_proxy_reciever(klass) ⇒ Object
17 18 19 |
# File 'lib/threadparty/threadpartyproxy.rb', line 17 def self.add_proxy_reciever(klass) @@proxables[klass.name.to_sym] = klass end |
Instance Method Details
#perform_proxy(a_class, &block) ⇒ Object
29 30 31 32 33 |
# File 'lib/threadparty/threadpartyproxy.rb', line 29 def perform_proxy(a_class, &block) party = @@proxables[a_class].new party.instance_eval(&block) @thread_party.to_process << party end |