Sha256: b7b486e4d2b098cc5762751a296c1921d18838bd2af8321a8433c13db9d1236c

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

module Lignite
  # FIXME: cannot handle replies
  class DirectCommands
    # @param conn [Connection]
    def initialize(conn = Connection.create)
      @op_compiler = OpCompiler.new
      @sender = MessageSender.new(conn)
    end

    def block(&body)
      locals = Variables.new
      bodyc = BodyCompiler.new(locals)
      bodyc.instance_exec(&body)
      @sender.direct_command(bodyc.bytes, local_size: locals.bytesize)
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lignite-0.1.2 lib/lignite/direct_commands.rb
lignite-0.1.1 lib/lignite/direct_commands.rb
lignite-0.1.0 lib/lignite/direct_commands.rb