Class: Lignite::DirectCommands
- Inherits:
-
Object
- Object
- Lignite::DirectCommands
- Defined in:
- lib/lignite/direct_commands.rb
Overview
FIXME: cannot handle replies
Instance Method Summary collapse
- #block(&body) ⇒ Object
-
#initialize(conn = Connection.create) ⇒ DirectCommands
constructor
A new instance of DirectCommands.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(conn = Connection.create) ⇒ DirectCommands
Returns a new instance of DirectCommands.
5 6 7 8 |
# File 'lib/lignite/direct_commands.rb', line 5 def initialize(conn = Connection.create) @op_compiler = OpCompiler.new @sender = MessageSender.new(conn) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/lignite/direct_commands.rb', line 17 def method_missing(name, *args) if @op_compiler.respond_to?(name) insb = @op_compiler.send(name, *args) @sender.direct_command(insb) else super end end |
Instance Method Details
#block(&body) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/lignite/direct_commands.rb', line 10 def block(&body) locals = Variables.new bodyc = BodyCompiler.new(locals) bodyc.instance_exec(&body) @sender.direct_command(bodyc.bytes, local_size: locals.bytesize) end |