Class: EmmyExtends::Mysql2::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/emmy_extends/mysql2/operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Operation

Returns a new instance of Operation.



8
9
10
# File 'lib/emmy_extends/mysql2/operation.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/emmy_extends/mysql2/operation.rb', line 6

def client
  @client
end

Instance Method Details

#syncObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/emmy_extends/mysql2/operation.rb', line 16

def sync
  Fiber.sync do |fiber|
    watch

    on :success do |response, operation, conn|
      fiber.resume response
    end

    on :error do |error, operation, conn|
      fiber.leave error
    end
  end
end

#to_aObject



30
31
32
# File 'lib/emmy_extends/mysql2/operation.rb', line 30

def to_a
  [client.socket, Mysql2::Watcher, @client, self, {notify_readable: true, notify_writable: false}]
end

#watchObject



12
13
14
# File 'lib/emmy_extends/mysql2/operation.rb', line 12

def watch
  @watch ||= EmmyMachine.watch(*self)
end